How to use the REST API to submit and follow jobs

368 views
Skip to first unread message

Julian Payne

unread,
Nov 22, 2013, 5:56:28 AM11/22/13
to jenkins...@googlegroups.com
I am trying to use the REST API to submit a job and follow it's progress. The problem that I am facing is that I can not see a fool-proof way to know what is the job number of the new job when I submit using job/MyJob/buildWithParameters

What I get back as JSON is designed for the UI but does not seem to give me an explicit handle to the new job.

Here are the different replies that I seem to get:

1. inQueue = true
    queueItem = null
    nextBuildNumber = <n>

    In this case I could suppose that my build will be <n> but as I need concurrent builds is this guaranteed?

2. inQueue = true
    queueItem = { number = <n> ... }

    Again I can see that there is a build in the queue but how can I be sure that is mine?

It seems that the REST API works fine for the Jenkins UI that does not track specific jobs but not really designed to submit and track a specific job?

Hopefully I missed something and this is not the case?

Thanks in advance

Daniel Beck

unread,
Nov 22, 2013, 1:00:08 PM11/22/13
to jenkins...@googlegroups.com
There's a (very) new plugin that seems to do exactly what you want:

https://github.com/Spedge/job-run-uuid
https://github.com/jenkinsci/job-run-uuid-plugin

Its developer wrote on the Jenkins devs list:

> The plugin allows you to request a build from the API but it returns a JSON snippet with a UUID for the job. This allows you to track the status of a job (using another part of the API) even before it has left the queue and has been assigned a run id - being in the queue is a valid state.
>
> I've found it very useful for executing batches (100+) of the same job but with different parameters, then tracking the status of them as they get completed.
>
> [...]
>
> I'm also happy to listen to any suggestions or recommendations for this :)

Regards
Daniel
> --
> 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.
> For more options, visit https://groups.google.com/groups/opt_out.

Julian Payne

unread,
Nov 23, 2013, 11:30:57 AM11/23/13
to jenkins...@googlegroups.com
Daniel,

That looks like exactly what I need.

Thanks for the information.

Regards,

Julian
Reply all
Reply to author
Forward
0 new messages