bndr/gojenkins

params in buildJob not working

Open

#164 aperta il 13 dic 2018

Vedi su GitHub
 (1 commento) (0 reazioni) (0 assegnatari)Go (454 fork)github user discovery
help wanted

Metriche repository

Star
 (903 star)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

I have the follow code:

func main() {
	jenkins := gojenkins.CreateJenkins(nil, "http://localhost:8080/", "master", "master")
	jenkins, err := jenkins.Init()
	if err != nil {
		panic(err)
	}
	i, err := jenkins.BuildJob("github-api", "Tags", "@ID12345")
	if err != nil {
		panic(err)
	}
	fmt.Println(i)
}

but the params are not going to jenkins, go empty if I force the function to complete the parameters, these values ​​will go correctly for the jenkins example:

func (j *Jenkins) BuildJob(name string, options ...interface{}) (int64, error) {
	job := Job{Jenkins: j, Raw: new(JobResponse), Base: "/job/" + name}
	var params map[string]string
	if len(options) > 0 {
		params, _ = options[0].(map[string]string)
		params = map[string]string{}
		params["Tags"] = "@ID12345"
	}
	fmt.Println(params)
	return job.InvokeSimple(params)
}

Guida contributor