How to get build ID effectively from remotely triggered builds.

25 views
Skip to first unread message

Yoo JinSun

unread,
Jun 9, 2020, 7:36:39 AM6/9/20
to Jenkins Users
Hello Jenkins Community!

Is there a way to reliably get the build number from a remotely triggered build? 

Here's the process I use to remotely trigger a build
1) POST a http request to trigger a build
 POST   https://{hostname}/job/{job_name}/build

2) From the response's Location header, get the queue number of the build
Location: https://{hostname}/queue/item/673730/

3) Repeatedly send GET request to the queue 
GET https://{hostname}/queue/item/673730/api/json?pretty=true

4) Get the build number
Response body:
{
 ...
 "id": 67370,
  "executable": {
    "number": 18073,
    "url": "https://{hostname}/job/{job_name}/18073/"
  }
}


5) Use the build number to get the current status, console output, etc. 
GET https://{hostname}/job/{job_name}/18073/consoleLogFull/api/json?pretty=true


Question is, is there a way for me to go from 1) to 3)? Or, another way to remotely build a Jenkins Job to 4) directly?
I'm seeing inefficiencies in having to continuously send a GET request at 2). Also, if the queue number becomes invalid (which happens a short while after build runs), then there's no way to get the build number. 
I CANNOT use the 'latest build' option, since multiple job trigger may occur at once. 

At least from the UI it seems that a job is given a build number as soon as it is triggered(through the UI)

Many suggestions appreciated, thx.

Vijay Gongle

unread,
Jun 19, 2020, 7:43:09 AM6/19/20
to jenkins...@googlegroups.com
Hello, 

I’m trying to build a jenkins job which is in jenkins server B from jenkins server A. 

How is it possible? 

Sent from my iPhone

On Jun 9, 2020, at 7:36 AM, Yoo JinSun <jinsun....@gmail.com> wrote:


--
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/a36d4800-69f6-4d8c-8ffa-66b6ce40318bo%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages