-
Bug
-
Resolution: Duplicate
-
Minor
-
None
When configuring Global Environment Variables in the "Manage Jenkins" view, the environment variables only seem to be accessible via the env global variable if it is inside the context of a node step.
I find this to be rather confusing, and would expect global variables defined in Jenkins to be visible in any scope within a Jenkinsfile.
See attached screenshot and the console output below for a reproduction case
node { sh 'printenv | grep -i foo' echo "env.FOO_PIPELINE is: ${env.FOO_PIPELINE}" } echo "Outside of a node: env.FOO_PIPELINE is: ${env.FOO_PIPELINE}"
Results in:
Started by user admin [Pipeline] node Running on master in /tmp/jenkins/workspace/printenv [Pipeline] { [Pipeline] sh [printenv] Running shell script + printenv + grep -i foo FOO_PIPELINE=beepboop [Pipeline] echo env.FOO_PIPELINE is: beepboop [Pipeline] } [Pipeline] // node [Pipeline] echo Outside of a node: env.FOO_PIPELINE is: null [Pipeline] End of Pipeline Finished: SUCCESS
- duplicates
-
JENKINS-43396 Global EnvironmentVariableNodeProperty does not show up in Pipeline unless in a node {...} block
- Resolved