import (
    "net/http"
    "strings"
    urlpkg "net/url"
)

url := "http://jenkins/job/test/buildWithParameters"
data := urlpkg.Values{}
data.Add("SERVER_NAME", "测试服")
data.Add("SERVER_URI", "refs/heads/master")
data.Add("CONFIG_URI", "refs/heads/master")

req, err := http.NewRequest("POST", url, strings.NewReader(data.Encode()))
if err != nil {
    panic(err.Error())
}
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
req.SetBasicAuth("wameidemao", "1151edd79316129baea8911ce078908130")
resp, err := http.DefaultClient.Do(req)

标签: none

添加新评论