0
votes

In a Jenkins pipeline, parameters defined in upstream job is not being passed to downstream job even "current build parameters" option is selected. When I try to echo the parameter value, it is null.

Example: I have checked "This is a parameterized build". There is a string parameter in upstream job called "version" with the default value as "abc". When I run echo $version on the downstream job, in console output I do not see a value being printed.

Environment info:

  • Jenkins Version: 2.89.3
  • O/S: CentOs 7

Jenkins installed plugin info:

  • Build with Parameters: 1.4
  • Parameterized Trigger plugin:2.35.2
2

2 Answers

2
votes

In the downstream job you need to set a variable to accept the parameter being passed.

Example: If foo parameter was passed from upstream job. The downstream should have a parameter (string or one of your choice) same name as foo and default value as $foo.

0
votes

Finally I found out that the way this parameter works in jenkins 1.x and 2.x versions is different. In the newer version of jenkins, all the down stream projects must be parameterized with the defined parameter and the empty value. However, in Jenkins 1.x was able to pass the parameter from upstream to downstream without defining the parameter in the upstream project. Using only "Current build parameter" was able to do the work but not anymore. Not sure If I am the only one finding it bizarre.