Reputation: 2426
I have two Jenkins Jobs - JobA and JobB.
I need to start execution of JobB when JobA has finished building and I need to pass the Job name (i.e. 'JobA') and the latest build number (the build that just completed) to JobB.
Along with these, I also need to pass the original parameters that were passed to JobA, to be passed to JobB
I have added a post build action in JobA - Trigger parameterized build on other projects and specified JobB in the projects to build. within this, I have also added a parameter - Current build parameters, which will pass the current parameters to the next job.
I have also added a build trigger in JobB - Build after other projects are built and specified JobA as the Project Name.
Now, how do I pass the jobName and buildNumber of JobA to JobB?
Upvotes: 5
Views: 16909
Reputation: 2426
So, I was able to figure this out myself:
I created 2 String parameters in JobB - JOBNAME and BUILDNUM
Then, in the Trigger parameterized build on other projects section within the Post-build Action of JobA, I added two things:
Predefined paramters:
JOBNAME=${JOB_NAME}
BUILDNUM=${BUILD_NUMBER}
Using these, I was able to pass the job name and build number along with all the current parameters to the next job.
Upvotes: 12