I have two jobs in Jenkins:
-
Job A: Build source + run unit tests, triggered by SCM changes. This is fast. It doesn't trigger anything by itself
-
Job B: Build installer. This takes some time. It is triggered by monitoring successful builds of job A ("Build after other projects are built").
It uses artifacts from job A.
It can happen that several job A builds are started while a single run of Job B is in progress.
Job A #1 -> triggers Job B #1
|
Job A #2 |
|
Job A #3 -. ` Job B #1 finishes
`-> triggers Job B #2
Job A #4 |
|
Job A #5 |
| ` Job B #2 finishes
`-----------> triggers job B #3
My question is: How can I figure out what build number of A triggered a certain build number of B, so in job B I can copy the artifacts from that exact build of job A?
The 'Copy Artifact' plugin allows specifying a specific build number, but where do I get it from?
Best Answer
One of least cumbersome and cheap ways to do this: you could pass the
A
${BUILD_NUMBER}
environment variable toB
by using Parametrized Build plugin. For example, definePARENT_BUILD_NUMBER
variable in B and the passPARENT_BUILD_NUMBER=$BUILD_NUMBER
fromA
toB
.