Can I get the Jenkins build ID that I called through its API?

Let's say I start the build by sending a GET request to /job/awesomesauce/build. Is it possible to get the id of the running assembly?

I know that I can try to access it /job/awesomesauce/lastBuild/api/json, but this will give me erroneous information if there are several starts at once. Also, there seems to be a slight delay (a few seconds) before it gives me information about the current build in progress.

+5
source share
2 answers

I had to do such things, and here is the workaround I used: I had a dummy parameter that I passed to the assembly (in my case it was the BUILD_ID of another assembly, in your case it could be a timestamp), I then requested and analyzed both the assembly queue api ( [server]/queue/api/...) and the regular api (in case the assembly is completed) for the assembly containing the corresponding parameter value.

+4
source

In the header of the HTTP response "location" you can get the identifier of the queue element. Then you can poll / queue / item // api / json to get its executable number, which is the assembly identifier.

+1
source

All Articles