Pass Jenkins Upstream Job Parameter to Downstream Job

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


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

41 thoughts on “Pass Jenkins Upstream Job Parameter to Downstream Job”

  1. 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?

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

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

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

  3. hi,
    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

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

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

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

  8. 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)

    1. But what do for pipeline jobs?

      If one of the downstream job fails then email should be sent to upstream job’s recipients and make upstream job as falied one.
      In this case how to send complete info like failure cause of downstream job and upstream job info which triggered the downstream job … !

      Please let me know any ideas if you have !

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

      1. Joydeep Tapadar

        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.

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

  10. 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?

    1. Hi Cris,

      Thanks for the query.

      I assume you meant, After Upstream job is finished. I hope you have followed my article since I have demonstrated the scenario to pass Build Number only.

      If Yes, then please could you refer the articles: & which might help to resolve the issue

      If issue still persist, then please could you share Upstream and Downstream job’s config from config.xml along with detailed error log

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

    1. 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]]

  12. Hi,
    Thanks for the article but can you suggest how to do the same with multi-branch pipeline. Basically i want to trigger another job from the main job using main job’s build_number through jenkins file.

    1. Hi Rinki,
      You can use build-job to achieve the same

      build job: 'Downstream Job', parameters: [[$class: 'StringParameterValue', name: 'Build_Number', value: env.BUILD_NUMBER, propagate:false]]

      If you want to trigger against any particular branch, then you can wrap this build job inside if loop

      if (env.BRANCH_NAME == 'develop') {
      build job:

      Hope this helps – happy learning !!

  13. I agree that there should be some sort of example how to pass the parameters to the target job. The current Parameterized Trigger Plugin page does not give good information about this. There could be e.g. what kind of syntax you should use in passing the parameters. skrii Apr 20 ’16 at 14:50

    1. Hi Stremove,
      Thanks for your feedback.
      To answer your queries : I would request you to consider the above 2 of my replies if you are using pipeline jobs or refer the main article in case you are using simple job.
      Keep questing !!

  14. Hi Ravi,
    Very useful article. I have a similar use case of ‘TARVINDER SINGH’.
    I have to Pass only one ‘int’ value from an upstream project to a downstream job. Can you please suggest, using properties file is the best way, or is there any other way or can we pass the value using System.setproperty to the downstream project?

    1. Hi Ravi,
      Sorry for the delay.
      Basically it depends on your upstream project configuration, whether you are using a parameter or need dynamic values.
      You can try using the appropriate method.
      If you are using pipeline, then you can send the parameter to downstream job easily, like :
      build job: ‘Downstream Job’, parameters: [[$class: ‘StringParameterValue’, name: ‘Build_Number’, value: env.BUILD_NUMBER, propagate:false]]

  15. Hello Ravi,

    Thanks for the article. Can you tell us how we can get downstream build details like build number or build status to upstream job which can be further used in next build of upstream job ?

    1. Hi Vinay,

      Thanks for your feedback.

      If I understood your requirement correctly, I guess you need to get the build number of the downstream job rather than passing upstream job build number into downstream.

      It is possible, and there are many ways to achieve it. Simplest would be use, below in your script

      def buildNumber = Jenkins.instance.getItem('jobName').lastSuccessfulBuild.number

      You might get access rejection, then you need to approve this method using In-process Script Approval

      Hope this helps !!

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top