jenkinsci / jenkinsci/workflow-aggregator-plugin

[JENKINS-28921] Can't access Jenkins Global Properties from Pipeline DSL

Open
#263 14 comments 0 reactions 0 assignees View on GitHub
component:pipeline imported-jira-issue priority:minor resolution:unresolved
Dominant language
No language data
Stars
225
Forks
125
PR merge metrics
No merged PRs in 30d

Description

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)

---
Originally reported by saan800, imported from: Can't access Jenkins Global Properties from Pipeline DSL


  • assignee: jglick
  • status: Reopened
  • priority: Minor
  • component(s): pipeline
  • resolution: Unresolved
  • votes: 2
  • watchers: 7
  • imported: 2025-12-08

Raw content of original issue

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)


environment

```
workflow-plugin: v1.8

jenkins: v1.616
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.