System Global variables in pipelines

31 views
Skip to first unread message

Richard Ginga

unread,
Mar 8, 2017, 8:06:24 AM3/8/17
to jenkins...@googlegroups.com
I have some logic in some stages the use System Global variables. I find that they are only available to the code within a node { } block. I have tried using env.variable, ${env.variable} and anything else I can find short of importing Jenkins.* and using methods there.

what am I missing? Is there a way to do this?

--
Dick Ginga
Build Engineer

Bill Dennis

unread,
Mar 8, 2017, 1:52:24 PM3/8/17
to Jenkins Users
I have found the same. There is an open jira for this here:
https://issues.jenkins-ci.org/browse/JENKINS-40455

Are you using declarative or scripted pipeline?

In declarative, I have found I can reference env vars configured in Jenkins in the environment section to set up job level environment:

environment {
jobVar = env.SOME_VAR
}

But I haven't checked if these job level environment variables are available in a script section that runs with 'agent none'

Most of the job work is done on a node / agent for my pipelines.

Bill

Richard Ginga

unread,
Mar 8, 2017, 1:57:53 PM3/8/17
to jenkins...@googlegroups.com
thanks for the validation anyway. I use scripted pipelines at this time. There always seems to be 4-5 ways to get things done in Jenkins/groovy. just thought i'd missed one.


Bill

--
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-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/27dd108d-2119-4879-9ffe-6a9ef16b3bd7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages