Pass Jenkins Upstream Job Parameter to Downstream Job

Topic Tools

When we are implementing CI/CD through Jenkins, sometimes there is a need of passing parameter from one job to another job.

Here I am going to demonstrate how to achieve the same.

First of all, Install the Jenkins Parameterized Trigger Plugin – Go to Manage Jenkins and then Click on Manage Plugins

jenkins-windows-slave-creation-1

manage plugins

Once done, go to your Upstream Jenkins Job and add the Post Build Action to send the parameter to Downstream Job

Jenkins-Parameter-Upstream-Downstream-01 Jenkins-Parameter-Upstream-Downstream-02

Fill the Downstream Job details and Add the Parameter as “Predefined parameters

Jenkins-Parameter-Upstream-Downstream-03

Now go to your Downstream Job and use the Build Trigger Option as “This project is parameterised” and you can use the Upstream Build Parameters – I have used the Build Number of Upstream Job

Jenkins-Parameter-Upstream-Downstream-04

Using inside the Build Job

Jenkins-Parameter-Upstream-Downstream-05

Now, trigger the Upstream Job

Jenkins-Parameter-Upstream-Downstream-06

Once the Upstream Job completed, Jenkins will trigger the Downstream Job with the predefined Parameter

Jenkins-Parameter-Upstream-Downstream-07

In my Case the Build number of Upstream Job was 24 and Downstream Build number is 22 as shown in below screensshot of Downstream Job

Jenkins-Parameter-Upstream-Downstream-08

You can verify the result that Jenkins is using Upstream Build Number in my Downstream Job

Jenkins-Parameter-Upstream-Downstream-09

In the same fashion you can use other Upstream Build Parameters and use them in your Downstream Jobs and create the Build/Delivery Pipeline.

Hope you enjoyed today’s article.

Stay tuned for more learning ….

1 comment… add one

  • Kim

    Good Article 🙂

Leave a Comment