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?
One of least cumbersome and cheap ways to do this:
you could pass the A
${BUILD_NUMBER}
environment variable to B
by using Parametrized Build plugin. For example, define PARENT_BUILD_NUMBER
variable in B and the pass PARENT_BUILD_NUMBER=$BUILD_NUMBER
from A
to B
.
Of course the option was right there in the Copy Artifact plugin...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With