gojenkins
gojenkins copied to clipboard
BuildID
The BuildID of the return value in func jenkins.BuildJob can not be used as parament of the func jenkins.GetBuild(jobname,number) directly. How to use the func jenkins.BuildJob to get the parament number in func jenkins.GetBuild(jobname,number)
The buidID returned by jenkins.BuildJob() is not the ID of the current triggered build, but the last build's id. For example, the id of the build triggered through jenkins.BuildJob() is 5, but the return buildId is 4.
@bndr Is it as designed?
buildJob should return a Queue Item, because there is a link in the location header in the response that points to /queue/item/<QueueId> which can be queried to get the build id.
This is definitely a bug.
I had meet the problem also.
So how do one get the right build number? Is there any other APIs can be leveraged?
Has there been any traction on this? I've tried triggering a build and then trying to call GetLastBuild()
immediately after I call BuildJob()
but it doesn't always return the newly created build. Also, could be a race condition as if there is another build triggered in between those calls.
I did some further investigation on our in house jenkins server. It is running a GET
request against the following url (https://jenkins.com/job/my_job/wfapi/runs?since=%232&fullStages=true&_=1511833825555
) every 2 seconds for a job. It seems like its using this to populate the UI with new jobs. Not sure if that's helpful to solving this.
通过上图方式可以拿到,但是很慢,效率是真的低;也就是说最好通过异步的方式来获取这个build id信息,否则用户真的会狂吐槽.