How to pass parameter from build batch job to build flow job

19 views
Skip to first unread message

nguyen

unread,
Mar 30, 2016, 6:52:10 PM3/30/16
to Jenkins Users
Hi,

I have two  build job A and B.
job A build by "Execute Windows Batch Command"
job B build by "Flow"

In job A, I set "This build is parameterized" -> String Parameter -> Name = VAR_REV and Default = 123
In job A  "Execute Windows Batch Command", I set as below

echo %VAR_REV%
set VAR_REV=456
echo %VAR_REV%
exit 0

In job A, I set "Post-build Actions"->"Trigger Parameterized build on other project" -> "Project to build" = B and "Current Build Parameter"

In job B "Flow", I set

def REV= build.environment.get("VAR_REV")
println REV


After I build job A, I have output of first echo of job A is 123 and output of second echo of job A is 456.
However, the output at job B is printing out 123.

What should I do to have the data 456 in job B?

Thanks,

Nguyen

Noel Yap

unread,
Mar 30, 2016, 7:02:28 PM3/30/16
to Jenkins Users
Job A isn't really setting VAR_REV. Instead, it's setting it in a local scope (ie it shells out, sets the env var in that shell, then exits the shell). Try using the Inject Environment Variable plugin.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/f6fe67fe-b94a-4794-ae1a-aec125650d75%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages