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


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


Using inside the Build Job


Now, trigger the Upstream Job


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


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


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


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 ….

31 comments… add one
  • Kim Link Reply

    Good Article 🙂

  • Pramod Link Reply

    Very nice article

  • Hussain Link Reply

    Goоd info. I’ve bookmarked it for later!

  • Nikhat Link Reply

    Very nice, But what if i just want to copy parameter of Upstream job and check if that parameter is passed to another job then I have to kill that job, any suggestions here? i don’t want to trigger any build, I just want parameter of one job into other to check some condition. how do I do that?

    • Thanks Nikhat for your query.
      The main purpose of using Parameterized Trigger Plugin is to trigger the downstream build with upstream build’s parameters.
      If you want to just verify, you can either create a new build job and just display the parameters you need from upstream job.
      Or you can use ‘Conditional BuildStep Plugin
      Or you can simply add the “Execute shell” step in your downstream build at start which will test if the build is triggered with upstream job with given parameter (lets say runbuild=false) and if the value is passed as false from upstream just exit (without running further steps) the downstream build.
      You can use groovy scripting as well. There are multiple ways if you want to cancel/stop the build.
      Or you can use Jenkins Cause and use API to fetch the upstream job’s values

  • Nikhat Link Reply

    Thank you so much Ravi for a very quick response…:-) I tried using conditional step plugin but I am stuck.
    Basically il tell you my scenario: I have job which disables all the jobs of that particular version passed in parameter , I have another build job in which I have a drop down list of versions I want to build, I want to block the build job if disabled job’s version is equal to version selected in build job from drop down.

    In execute Shell script in run condition plugin my version parameter(from disable job)value is coming blank.
    thanks alott… for help.

    • Hi Nikhat,
      Thanks for providing your requirement.
      Please could you elaborate what error you are getting and how are you passing the parameter and fetching in downstream job ?
      I believe you have followed the steps provided in this article and you have defined the correct syntax
      Someone wanted to trigger the job only if a concrete variable (i.e.: “VARIABLE”) has been defined so checking “invert” option and using the below condition worked for him:
      Explanation: The conditional build expecting is just a “true” / other value, so if VARIABLE has no value it will leave a simple “true” in the field.
      Please see if this fits to your requirement, else please share the logs, conditions – thank you

  • Nikhat Link Reply

    I am trying to fetch value of job 1 from jenkins API but getting below issue:
    Traceback (most recent call last):
    File “”, line 1, in ?
    ImportError: No module named json

    • Have you configured the Jenkins Parameterized Trigger Plugin.

      Once done, go to your Upstream Jenkins Job and add the Post Build Action to send the parameter to Downstream Job
      Fill the Downstream Job details and Add the Parameter as “Predefined parameters”
      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 % since I was using Windows and $ will be used in *nix jobs.
      Please refer the post

      Then you can use the Upstream job’s parameter/variable in downstream job and then either use Conditional Step Plugin Or use any shell/python script to check the condition and terminate/proceed the rest of the steps

  • Misab Link Reply

    Hello, nice share.

  • krishi Link Reply

    I wanted to select the particular build number manually in jenkins.
    For example i have multiple jobs from which i have to select one particular successful job.
    Can you explain how it is possible using pipeline script or using jenkins job.


    Thanks a ton for this simple and informative article. I couldn’t find this info anywhere else. God bless you


    I had to create dynamic parameters in the upstream job and pass it to downstream job. This method only passes the parameters already with the upstream job when it start(either user provided or provided by jenkins). For using other variables that are created inside the upstream job, I used the parameters file. So add : “Parameters from properties file” and put all the variables in KEY=VALUE format in that file . Create this file in upstream job.

    This is for anyone having use case as mine.

  • venkat Link Reply

    Very Good article

  • Rex Link Reply

    Remarkable issues here. I’m very satisfied to
    look your post. Thanks a lot and I’m taking a look forward to contact you.
    Will you please drop me a mail?

  • sudsawan Link Reply

    There is very good option to pass parameters to downstream job using properties file.

    Please select :
    Post-build Actions –> Trigger parameterized build on other projects –> Build Trigger –> Add Parameters –> Parameters from properties file

    Comma separated list of absolute or relative paths to file(s) that contains the parameters for the new project. Relative paths are originated from the workspace. The file should have KEY=value pairs, one per line (Java properties file format). Backslashes are used for escaping, so use “\\” for a single backslash.
    Current build parameters and/or environment variables can be used in form: ${PARAM} or $PARAM.

    (from Jenkins Parameterized Trigger plugin)

    • Thanks for sharing Sudsawan. It totally depends on the project requirement, which option is required to pass the parameters. Appreciate your inputs.

  • Sid Link Reply

    Is there a way we can pass parameters to upstream job from a downstream job??

    • Hi Sid,
      Thanks for your query.
      But in reality you won’t need to pass the parameter from downstream job to upstream job.
      Why ?
      Because, An upstream job is a configured project that triggers a project as of its execution, whereas a downstream job is a configured project that is triggered as part of a execution of pipeline, that means the flow will always go from Upstream –> Downstream.
      In case you want the other way round then your’s (so called) downstream job is actually working as upstream job and you can follow the above mentioned process to achieve the result.
      Hope this helps…

      • Joydeep Tapadar Link Reply

        How can show all stages from downstream jobs to upstream jobs. Basically we want to see each stages from upstream and downstream jobs within any one job. Is there a way to display results of both jobs in one pipeline console output. Thanks in advance.

        • You can use Views with Delivery Pipeline, Build Pipeline, etc in order to display everything at one screen

  • Laxma Reddy Link Reply

    Hi Ravi Varma,

    Useful artifical , but only one thing is missed is in the upstream job, predefined parameters we need to use UPSTREAM_BUILD_NUMBER=$BUILD_NUMBER , if we want to pass BUILD_NUMBER to the downstream job. Similarly we can define more parameters if we want.

    Thanks for the useful artical.

    • Thanks Laxma for your feedback, however this is already described in the above post (please refer 5th Diagram from top).
      Keep questing!!

  • Cris Link Reply

    After the Downstream job is finished I need in a post-build action to get the number of the Downstream job. How can I do that? I tried with TRIGGERED_BUILD_NUMBER_WAVE- but I got ava.lang.IllegalArgumentException: Illegal choice for parameter. Any ideea?

  • Deep Link Reply

    I have two pipelines, one for CI and one for CD…I want the variables from CI pipeline to be passed to CD pipeline.. how to do this in pipeline type of jobs

    • Hi Deep,

      You can use below example in your upstream job:

      node {
      var1 = “var1”
      var2 = “var2”
      build job: ‘downstream-job’, parameters: [[$class: ‘StringParameterValue’, name: ‘variable1’, value: var1], [$class: ‘StringParameterValue’, name: ‘variable2’, value: var2]]

  • Abcd Link Reply

    Thanks a ton. It works for me! I ‘m using Jenkins on Windows, was bit confused earlier.

Leave a Comment