-
Bug
-
Resolution: Unresolved
-
Minor
-
None
-
workflow-plugin: v1.8
jenkins: v1.616
When I try to access the Global Properties environment variables (Manage Jenkins > Configure System > Global Properties) I either get null or an error (details below)
To replicate issue:
- Browse to Manage Jenkins > Configure System
- under the "Global Properties" make sure "Environment variables" is checked
- under the "Global Properties" > "Environment variables" add a new variable
- name = TEST_VAR
- value = some value
- In left navigation add "New Item"
- my job was named "workflow-test"
- select "Workflow" job type
- under the "Workflow" heading
- Definition: "Groovy CPS DSL"
- Script:
echo "JOB_NAME from env: ${env.JOB_NAME}" echo "global property from env: ${env.TEST_VAR}" echo "global property: ${TEST_VAR}"
Build workflow job and go to Console output
from the output can see that the above script evaluates to:
echo "JOB_NAME from env: ${env.JOB_NAME}" -> "JOB_NAME from env: workflow-test" (worked) echo "global property from env: ${env.TEST_VAR}" -> "global property from env: null" (didn't work, but didn't error) echo "global property: ${TEST_VAR}" -> ERROR groovy.lang.MissingPropertyException: No such property: TEST_VAR for class: WorkflowScript at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:50) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.getProperty(ScriptBytecodeAdapter.java:454) at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.getProperty(DefaultInvoker.java:25) at com.cloudbees.groovy.cps.impl.PropertyAccessBlock.rawGet(PropertyAccessBlock.java:17) at WorkflowScript.run(WorkflowScript:25)