gojenkins icon indicating copy to clipboard operation
gojenkins copied to clipboard

BuildID

Open menghao11 opened this issue 7 years ago • 7 comments

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)

menghao11 avatar Jun 01 '17 06:06 menghao11

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?

supereagle avatar Jun 01 '17 09:06 supereagle

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.

bndr avatar Jun 01 '17 09:06 bndr

I had meet the problem also.

laimu avatar Jul 29 '17 06:07 laimu

So how do one get the right build number? Is there any other APIs can be leveraged?

thoslin avatar Sep 27 '17 12:09 thoslin

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.

cpheps avatar Nov 28 '17 01:11 cpheps

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.

cpheps avatar Nov 28 '17 01:11 cpheps

image

通过上图方式可以拿到,但是很慢,效率是真的低;也就是说最好通过异步的方式来获取这个build id信息,否则用户真的会狂吐槽.

HQ1363 avatar Aug 10 '20 12:08 HQ1363