Synchronous REST API call to execute a job

249 views
Skip to first unread message

Alan Evangelista

unread,
Aug 25, 2015, 3:27:11 AM8/25/15
to jenkins...@googlegroups.com
Hi.

I am trying to create a synchronous REST API call to execute a job. I
was able to submit a job using the Jenkins REST API, but I am not able
to get the build ID so I can query if the build completed and was
successful. I am aware that the build ID is not obvious, as there may be
no idle executors and build could be added to the build queue. I tried
to use the idea proposed in
https://issues.jenkins-ci.org/browse/JENKINS-12827 , but Location header
in HTTP response always point to job URL
(eg http://<jenkins_server>/job/<job_name>). I am using jenkins 1.6.2.0.
Is this a known bug or I am doing something wrong?


Regards,
Alan Evangelista

Daniel Beck

unread,
Aug 25, 2015, 4:31:24 AM8/25/15
to jenkins...@googlegroups.com

On 25.08.2015, at 09:26, Alan Evangelista <ala...@linux.vnet.ibm.com> wrote:

> I tried to use the idea proposed in https://issues.jenkins-ci.org/browse/JENKINS-12827 , but Location header in HTTP response always point to job URL

Did you follow the instructions on /job/<job name>/api to start the build? There are other suggestions out there how to do this (JSON parameter) and aren't really 'API' -- you're just imitating browser behavior.

Alan Evangelista

unread,
Aug 25, 2015, 9:58:01 AM8/25/15
to jenkins...@googlegroups.com
I followed the instructions on https://wiki.jenkins-ci.org/display/JENKINS/Remote+access+API, which uses the /job/<job_name>/build URL and the JSON parameter. I thought this was the official Jenkins REST API documentation?

Accessing /job/<job name>/api instructions at my Jenkins server, I read:


"
Perform a build
    To programmatically schedule a new build, post to this URL (<server_url>/job/<job_name>/build). If the build has parameters, post to this URL
(<server_url>/job/<job_name>/buildWithParameters) and provide the parameters as form data.
"

I'm confused. Should I use /buildWithParameters REST call instead of /build?
Reply all
Reply to author
Forward
0 new messages