mirror of
https://github.com/appleboy/drone-jenkins.git
synced 2026-06-04 10:15:02 +08:00
+1
-1
@@ -23,5 +23,5 @@ _testmain.go
|
||||
*.test
|
||||
*.prof
|
||||
vendor
|
||||
drone-telegram
|
||||
drone-jenkins
|
||||
coverage.txt
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.PHONY: install build test html update docker_build docker_image docker_deploy clean
|
||||
.PHONY: install build test html update docker_build docker_image docker docker_deploy clean
|
||||
|
||||
VERSION := $(shell git describe --tags || git rev-parse --short HEAD)
|
||||
DEPLOY_ACCOUNT := "appleboy"
|
||||
|
||||
@@ -42,6 +42,7 @@ Execute from the working directory:
|
||||
|
||||
```
|
||||
docker run --rm \
|
||||
-e PLUGIN_BASE_URL=http://example.com \
|
||||
-e PLUGIN_USERNAME=xxxxxxx \
|
||||
-e PLUGIN_TOKEN=xxxxxxx \
|
||||
-e PLUGIN_JOB=xxxxxxx \
|
||||
|
||||
@@ -34,7 +34,6 @@ func NewJenkins(auth *Auth, url string) *Jenkins {
|
||||
|
||||
func (jenkins *Jenkins) buildURL(path string, params url.Values) (requestURL string) {
|
||||
requestURL = jenkins.BaseURL + path
|
||||
fmt.Println(requestURL)
|
||||
if params != nil {
|
||||
queryString := params.Encode()
|
||||
if queryString != "" {
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestMissingConfig(t *testing.T) {
|
||||
var plugin Plugin
|
||||
|
||||
err := plugin.Exec()
|
||||
|
||||
assert.NotNil(t, err)
|
||||
}
|
||||
|
||||
func TestMissingJenkinsConfig(t *testing.T) {
|
||||
plugin := Plugin{
|
||||
Config: Config{
|
||||
BaseURL: "http://example.com",
|
||||
},
|
||||
}
|
||||
|
||||
err := plugin.Exec()
|
||||
|
||||
assert.NotNil(t, err)
|
||||
}
|
||||
|
||||
func TestPluginTriggerBuild(t *testing.T) {
|
||||
plugin := Plugin{
|
||||
Repo: Repo{
|
||||
Name: "go-hello",
|
||||
Owner: "appleboy",
|
||||
},
|
||||
Build: Build{
|
||||
Number: 101,
|
||||
Status: "success",
|
||||
Link: "https://github.com/appleboy/go-hello",
|
||||
Author: "Bo-Yi Wu",
|
||||
Branch: "master",
|
||||
Message: "update by drone line plugin.",
|
||||
Commit: "e7c4f0a63ceeb42a39ac7806f7b51f3f0d204fd2",
|
||||
},
|
||||
|
||||
Config: Config{
|
||||
BaseURL: "http://example.com",
|
||||
Username: "foo",
|
||||
Token: "bar",
|
||||
Job: []string{"drone-jenkins"},
|
||||
},
|
||||
}
|
||||
|
||||
err := plugin.Exec()
|
||||
|
||||
assert.Nil(t, err)
|
||||
}
|
||||
|
||||
func TestTrimElement(t *testing.T) {
|
||||
var input, result []string
|
||||
|
||||
input = []string{"1", " ", "3"}
|
||||
result = []string{"1", "3"}
|
||||
|
||||
assert.Equal(t, result, trimElement(input))
|
||||
|
||||
input = []string{"1", "2"}
|
||||
result = []string{"1", "2"}
|
||||
|
||||
assert.Equal(t, result, trimElement(input))
|
||||
}
|
||||
Reference in New Issue
Block a user