1
There’s an API endpoint at http://10.211.213.138:8080/job/TE-mobius/api/json?pretty=true
that has a nextBuildNumber
key.
It also has
"queueItem" : {
"blocked" : false,
"buildable" : true,
"id" : 119,
"inQueueSince" : 1401783373284,
"params" : "",
"stuck" : false,
"task" : {
"name" : "YourJobName",
"url" : "http://jenkins/job/YourJobName/"
},
"url" : "queue/item/119/",
"why" : "Waiting for next available executor",
"buildableStartMilliseconds" : 1401783373290,
"pending" : false
}
with some basic information about that pending build. Some of the build information you’re trying to print in your code won’t exist in Jenkins until the build has started.
Unfortunately, this will only let you get the build number of the next pending build. If you have a parameterised build and multiple builds in the queue for one job, I’m not aware of any way to get the build numbers of the other pending builds. You might have to write a plugin if you need to get those.
Source:stackexchange.com