Jenkins : Passing a parameter from one job to another used Parameterized Trigger Plugin. Not Working

14.1k views Asked by At

i have given as: in post build action's Parameterized Trigger Plugin

project to build : project B
Trigger when build is   : complete
Trigger build without paramater : disabled
in predefined param sections: 
Temp=${BUILD_NUMBER}
branch=$BRANCH
branch1="hai"

in project B 's Execute shell i have given as:

echo "Testing..." $Temp
echo $branch
echo $branch1

FYI, i have given BRANCH=development

console output of the Project B:

+ echo Testing...

Testing...

+ echo

+ echo

======

seems variable is not promoted.

2

There are 2 answers

1
user7509501 On BEST ANSWER

Select the "Trigger/call builds on other projects" in build section instead of post build section.

In the Build Triggers,

Projects to build "project B"

"Select" Block until the triggered projects finish their builds Fail this build step if the triggered build is worse or equal to "Failure"
Mark this build as failure if the triggered build is worse or equal to "Failure"
Mark this build as unstable if the triggered build is worse or equal to "UNSTABLE"

In the predefined parameters,

Temp=${BUILD_NUMBER}

branch=$BRANCH

branch1="hai"

In your " project B " projects,

"Click the build is parameterized option "

And form the variable.

1
Wael Gabsi On

On the 2nd job on the General section tick the box "This project is parameterized" and define the name of the parameter you are passing form the 1st job.enter image description here