3
votes

I am triggering builds with parameters in Jenkins using Python request to the http://jenkins:8080/view/projectAlpha/job/deploy_job_with_params/build and I don't get any queue or build numbers to identify my build.

According to Jenkins' /api page for the above url:

"To programmatically schedule a new build, post to this URL (means the /build url - RaamEEIL). If the build has parameters, post to this URL (means the /buildWithParameters url - RaamEEIL) and provide the parameters as form data. Either way, the successful queueing will result in 201 status code with Location HTTP header pointing the URL of the item in the queue."

However, instead of getting the queue's url (e.g. http://jenkins:8080/queue/item/21038/api/json) in the location header that returns when depploying the build, I get the url http://jenkins:8080/view/projectAlpha/job/deploy_job_with_params/ so basically I don't get any queue number or build number

I read a suggestion for a workaround, to send an additional parameter with some id, which I can use to verify that the latest build is my build or use it to search through a list of builds until I find the correct build.

Thanks.

1

1 Answers

2
votes

Well, it turns out that I got things mixed up. This seems to happen to many others, so here is some info.

/build url - returns location = the url of the job. doesn't include info on your build

/buildWithParameters url - returns location = the url of the queue item for your build

According to Daniel Beck's comment on https://issues.jenkins-ci.org/browse/JENKINS-30317 -

(By "This" the author means the /build url)

That's the problem. This is not actually the API. As I wrote before, the API as documented uses /buildWithParameters for parameterized builds. This is pretending to be a web browser.

...because web browsers would get redirected to a blank 404 error page. Again, you're not actually using the API here, you're pretending to be a web browser.

So, although the API page states you can request the /build url, if you want to get the queue item url for your build as the 'location' header, you must request the /buildWithParameters url.