Is it possible to retrieve the ID of Jenkins built through its API?

Suppose I trigger the build by sending a GET request to /job/awesomesauce/build. Is it possible to retrieve the ID that triggered the build?

I know that I can try to access /job/awesomesauce/lastBuild/api/json, but if there are multiple builds running at the same time, this will give me wrong information. Also, in providing me There seems to be a slight delay (a few seconds) before information about the currently running build.

I have to do this kind of thing, this is a workaround I use: I have a dummy parameter that I pass to the build (in my case, it is the BUILD_ID of another build; in your case, it It may be a timestamp), I then query and parse the build queue api ([server]/queue/api/…) and the regular api (if the build has been completed), the build containing the appropriate parameter values.

Suppose I trigger the build by sending a GET request to /job/awesomesauce/build. Is it possible to retrieve the ID that triggered the build?

I know that I can try to access /job/awesomesauce/lastBuild/api/json, but if there are multiple builds running at the same time, this will give me wrong information. Also, in providing me There seems to be a slight delay (a few seconds) before the information about the currently running build.

I have to do this kind of thing, this is what I use A workaround: I have a dummy parameter that I pass to the build (in my case, it is the BUILD_ID of another build; in your case, it may be a timestamp), I then query and parse Build queue api ([server] / queue / api / …) and regular api (if the build is completed), including the construction of appropriate parameter values.

Leave a Comment

Your email address will not be published.