#24 Fix getting job's build when Jenkins URL is set

This commit is contained in:
Tomasz Sęk 2019-06-05 21:45:49 +02:00
parent b86db676ed
commit 8c6f71bd10
No known key found for this signature in database
GPG Key ID: DC356D23F6A644D0
2 changed files with 34 additions and 0 deletions

View File

@ -0,0 +1,30 @@
package client
import (
"net/url"
"github.com/bndr/gojenkins"
)
func (jenkins *jenkins) GetBuild(jobName string, number int64) (*gojenkins.Build, error) {
job, err := jenkins.GetJob(jobName)
if err != nil {
return nil, err
}
// https://github.com/bndr/gojenkins/issues/176
// workaround begin
jobURL, err := url.Parse(job.Raw.URL)
if err != nil {
return nil, err
}
job.Raw.URL = jobURL.RequestURI()
// workaround end
build, err := job.GetBuild(number)
if err != nil {
return nil, err
}
return build, nil
}

View File

@ -111,6 +111,10 @@ Jenkins.instance.save()`, numberOfExecutors),
"1-casc.yaml": fmt.Sprintf(`
jenkins:
systemMessage: "%s"`, systemMessage),
"2-casc.yaml": `
unclassified:
location:
url: http://external-jenkins-url:8080`,
},
}