Passing environment variables across Build Flow jobs

215 views
Skip to first unread message

Sagu Feert

unread,
Apr 22, 2014, 5:51:12 PM4/22/14
to jenkins...@googlegroups.com
I have 2 build flow jobs: bf1 and bf2.
bf1 triggers bf2, and I'd like bf1 to pass some environment variables to bf2.

I tried using the 'Parameterized Trigger Plug-in' to pass variables between the two and that didn't work.

I also tried triggering bf2 in the bf1 DSL like this:
build( "bf2", param1: someParam)

and that didn't work either.

Is this simply not possible?

Marc MacIntyre

unread,
Apr 22, 2014, 5:52:27 PM4/22/14
to jenkins...@googlegroups.com
You need both of those solutions: set up bf2 to take the parameters you want, and have bf1 pass them in.


--
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.
For more options, visit https://groups.google.com/d/optout.



--
Marc MacIntyre

Svg Feert

unread,
Apr 22, 2014, 6:03:06 PM4/22/14
to jenkins...@googlegroups.com
Thanks Marc.

I added this in the bf1 DSL:
build( "bf2", param1: 'asd')

Then in bf2:
- I checked the 'This build is parameterized' box
- I specified the param name as param1 and did not give a default value.
- In the DSL I said:
def env=System.getenv()
env.each{
println it
}

When bf2 runs, I see a bunch of environment variables, but not param1.

Can you please tell me where I am going wrong?

Thanks,
Sagu




--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/sq9M0mtcIYo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-use...@googlegroups.com.

Marc MacIntyre

unread,
Apr 22, 2014, 6:05:24 PM4/22/14
to jenkins...@googlegroups.com
You want to get the parameter, not the environment variable. 

Sent from my iPhone

Svg Feert

unread,
Apr 22, 2014, 6:12:18 PM4/22/14
to jenkins...@googlegroups.com
Sorry Marc, I don't understand how to do that.

For other regular jobs I simply access parameters as environment variables (by asking the jobs to execute a shell script).

I can't do that in the DSL for bf2, and trying to print $param1 doesn't work.

How do I access that parameter in bf2? Any help you can give will be greatly appreciated.

Sagu


Marc MacIntyre

unread,
Apr 22, 2014, 6:15:44 PM4/22/14
to jenkins...@googlegroups.com
params = params.get('PARAM_NAME', 'DEFAULT_VALUE')

Marc MacIntyre

unread,
Apr 22, 2014, 6:16:08 PM4/22/14
to jenkins...@googlegroups.com
Ugh, should have read
p = params.get('PARAM_NAME', 'DEFAULT_VALUE')
--
Marc MacIntyre

S Feert

unread,
Apr 22, 2014, 6:18:46 PM4/22/14
to jenkins...@googlegroups.com
Awesome! That worked.

Thanks a ton! :)

Sagu

Reply all
Reply to author
Forward
0 new messages