Reputation: 4523
Jenkins JobA triggers JobB as a subproject.
Is there any way that I can force JobB to have the same build number as JobA?
I am currently passing an environment variable into JobB so that JobB can use the correct number during its build. But it's still confusing having JobA and JobB have different build numbers.
I am also using the "Next Build Number Plugin", but JobA and JobB's build numbers keep drifting apart over time as JobA fails before it calls JobB, forcing me to come back and manually fix it.
Upvotes: 0
Views: 1052
Reputation: 2330
In the parent job get the next build number, substract by 1 if needed and pass it to child job:
cat $JENKINS_HOME/jobs/$JOB_NAME/nextBuildNumber
And output it to
$JENKINS_HOME/jobs/$CHILD_JOB_NAME/nextBuildNumber
You may or may not have to install the NextBuildNumber plugin:
Also, there is a CLI command set-next-build-number. Try executing jenkins CLI help.
Upvotes: 0
Reputation: 27495
You should consider Build Name Setter Plugin, as it allows setting a BUILD_NUMBER
through a variable. Configure it to use something like $parentBuildNumber
Now, in JobB configure a text/string parameter, parentBuildNumber
.
When you trigger JobB from JobA, you should be using Parameterized Trigger Plugin.
There configure a predefined parameter set as parentBuildNumber=$BUILD_NUMBER
Upvotes: 1