Get Build ID when we invoke a Jenkins Job from REST API

2,387 views
Skip to first unread message

Arjun K.N

unread,
Sep 18, 2015, 1:27:17 AM9/18/15
to Jenkins Users
Hi All,
  
I am new to Jenkins Rest API calls. I am trying to create a script which will kick Jenkins JOB and wait for the completion of JOB.

I am kicking a job using below command:

curl -k -x <Proxy> https://<URL>/jenkins/job/DOLPHIN-Test/build --user dolphin:swimwithme --data token=<Token>

I do not get any response when i execute the command. I need to get the Build Number for me to query the status. 

Please let me know the best way for the problem.

Regards
Arjun
Message has been deleted

Victor Martinez

unread,
Sep 18, 2015, 2:24:11 AM9/18/15
to Jenkins Users
You can use Jenkins CLI in order to run builds and wait for the result, further details:

https://<URL>/jenkins/cli
https://<URL>/jenkins/cli/command/build

java -jar jenkins-cli.jar -s https://<URL>/jenkins/ build JOB [-c] [-f] [-p] [-r N] [-s] [-v] [-w]
Starts a build, and optionally waits for a completion.
Aside from general scripting use, this command can be
used to invoke another job from within a build of one job.
With the -s option, this command changes the exit code based on
the outcome of the build (exit code 0 indicates a success)
and interrupting the command will interrupt the job.
With the -f option, this command changes the exit code based on
the outcome of the build (exit code 0 indicates a success)
however, unlike -s, interrupting the command will not interrupt
the job (exit code 125 indicates the command was interrupted)
With the -c option, a build will only run if there has been
an SCM change

 JOB : Name of the job to build
 -c  : Check for SCM changes before starting the build, and if there's no
       change, exit without doing a build
 -f  : Follow the build progress. Like -s only interrupts are not passed
       through to the build.
 -p  : Specify the build parameters in the key=value format.
 -s  : Wait until the completion/abortion of the command. Interrupts are passed
       through to the build.
 -v  : Prints out the console output of the build. Use with -s
 -w  : Wait until the start of the command


Cheers

Daniel Beck

unread,
Sep 18, 2015, 9:11:38 AM9/18/15
to jenkins...@googlegroups.com
See my comment here:

https://issues.jenkins-ci.org/browse/JENKINS-12827?focusedCommentId=201381&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-201381
> --
> You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/555e36df-bf53-4f29-9896-0e19ac0ec57f%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages