0

How does the application get back the BUILD_ID or BUILD_NUMBER that their HTTP Post has caused when submitting the build request by performing an HTTP Post to the Jenkins CI Job using .../buildWithParameters?token=TOKEN to kick off a build?

For example, if I have 6 applications running that each kick off the same Jenkins CI job, each build would get a different build_id, but how does each application know which particular build_id corresponds to their trigger request?

Nakilon
  • 34,866
  • 14
  • 107
  • 142
mzvertigo
  • 1
  • 1
  • 2
  • Possible duplicate of [Retrieve id of remotely triggered jenkins job](http://stackoverflow.com/questions/24507262/retrieve-id-of-remotely-triggered-jenkins-job) – Kyll May 22 '17 at 00:08

1 Answers1

2

Once they trigger a build, get the build_id and store it

.../api/xml?xpath=//lastBuild/number/text()

Will get you the build number of the currently running job. Assuming your job goes faster then a few seconds, using the lastBuild/number/text() will get you the build number that you can then use later to retrieve whatever you want.

aflat
  • 4,329
  • 1
  • 20
  • 23
  • Hi George, thanks for the reply. Would there still be race conditions to worry about amongst all the jobs? – mzvertigo Jun 24 '11 at 17:14
  • As soon as the job is started that build number is valid, no race condition that I could see, and that is how I kick some of my builds. – aflat Jun 25 '11 at 01:38
  • 2
    The problem is when two builds are submitted simultaneously. lastBuild will no longer point to the build you've submitted. – Danail Nachev Feb 24 '12 at 13:54