Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 762
soundararajan.c Avatar asked Dec 19 '22 09:12

soundararajan.c


2 Answers

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.

like image 190
user7509501 Avatar answered Jan 23 '23 05:01

user7509501


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

like image 34
Wael Gabsi Avatar answered Jan 23 '23 05:01

Wael Gabsi