Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-28921

Can't access Jenkins Global Properties from Pipeline DSL

    XMLWordPrintable

Details

    • Bug
    • Status: Reopened (View Workflow)
    • Minor
    • Resolution: Unresolved
    • pipeline
    • None
    • workflow-plugin: v1.8
      jenkins: v1.616

    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)
      
      

      Attachments

        Activity

          saan800 Sandra Greenhalgh created issue -
          saan800 Sandra Greenhalgh made changes -
          Field Original Value New Value
          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"
          - 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
          - echo "JOB_NAME from env: ${env.JOB_NAME}"
                - WORKS: it prints the name of the workflow job
          - echo "global property from env: ${env.TEST_VAR}"
                - DOES NOT WORK: ${env.TEST_VAR} evaluates to null
          - echo "global property: ${TEST_VAR}"
                - ERRORS:
          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)


           
          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"
          - 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
          - echo "JOB_NAME from env: ${env.JOB_NAME}"
                -- WORKS: it prints the name of the workflow job
          - echo "global property from env: ${env.TEST_VAR}"
                -- DOES NOT WORK: ${env.TEST_VAR} evaluates to null
          - echo "global property: ${TEST_VAR}"
                -- ERRORS:
          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)


           
          saan800 Sandra Greenhalgh made changes -
          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"
          - 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
          - echo "JOB_NAME from env: ${env.JOB_NAME}"
                -- WORKS: it prints the name of the workflow job
          - echo "global property from env: ${env.TEST_VAR}"
                -- DOES NOT WORK: ${env.TEST_VAR} evaluates to null
          - echo "global property: ${TEST_VAR}"
                -- ERRORS:
          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)


           
          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"
          - select "Workflow" job type
          - under the "Workflow" heading
             -- Definition: "Groovy CPS DSL"
             -- Script:


          {code:java}
          echo "JOB_NAME from env: ${env.JOB_NAME}"
          echo "global property from env: ${env.TEST_VAR}"
          echo "global property: ${TEST_VAR}"
          {code}

          - Build workflow job and go to Console output
          - echo "JOB_NAME from env: ${env.JOB_NAME}"
                -- WORKS: it prints the name of the workflow job
          - echo "global property from env: ${env.TEST_VAR}"
                -- DOES NOT WORK: ${env.TEST_VAR} evaluates to null
          - echo "global property: ${TEST_VAR}"
                -- ERRORS:

          {code:java}
          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)

          {code}


           
          saan800 Sandra Greenhalgh made changes -
          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"
          - select "Workflow" job type
          - under the "Workflow" heading
             -- Definition: "Groovy CPS DSL"
             -- Script:


          {code:java}
          echo "JOB_NAME from env: ${env.JOB_NAME}"
          echo "global property from env: ${env.TEST_VAR}"
          echo "global property: ${TEST_VAR}"
          {code}

          - Build workflow job and go to Console output
          - echo "JOB_NAME from env: ${env.JOB_NAME}"
                -- WORKS: it prints the name of the workflow job
          - echo "global property from env: ${env.TEST_VAR}"
                -- DOES NOT WORK: ${env.TEST_VAR} evaluates to null
          - echo "global property: ${TEST_VAR}"
                -- ERRORS:

          {code:java}
          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)

          {code}


           
          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"
          - select "Workflow" job type
          - under the "Workflow" heading
             -- Definition: "Groovy CPS DSL"
             -- Script:


          {code:java}
          echo "JOB_NAME from env: ${env.JOB_NAME}"
          echo "global property from env: ${env.TEST_VAR}"
          echo "global property: ${TEST_VAR}"
          {code}

          - Build workflow job and go to Console output
          - echo "JOB_NAME from env: ${env.JOB_NAME}"
                -- WORKS: it prints the name of the workflow job
          - {noformat}
          echo "global property from env: ${env.TEST_VAR}"
          {noformat}

                -- DOES NOT WORK: ${env.TEST_VAR} evaluates to null
          - echo "global property: ${TEST_VAR}"
                -- ERRORS:

          {code:java}
          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)

          {code}


           
          saan800 Sandra Greenhalgh made changes -
          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"
          - select "Workflow" job type
          - under the "Workflow" heading
             -- Definition: "Groovy CPS DSL"
             -- Script:


          {code:java}
          echo "JOB_NAME from env: ${env.JOB_NAME}"
          echo "global property from env: ${env.TEST_VAR}"
          echo "global property: ${TEST_VAR}"
          {code}

          - Build workflow job and go to Console output
          - echo "JOB_NAME from env: ${env.JOB_NAME}"
                -- WORKS: it prints the name of the workflow job
          - {noformat}
          echo "global property from env: ${env.TEST_VAR}"
          {noformat}

                -- DOES NOT WORK: ${env.TEST_VAR} evaluates to null
          - echo "global property: ${TEST_VAR}"
                -- ERRORS:

          {code:java}
          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)

          {code}


           
          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"
          - select "Workflow" job type
          - under the "Workflow" heading
             -- Definition: "Groovy CPS DSL"
             -- Script:


          {code:java}
          echo "JOB_NAME from env: ${env.JOB_NAME}"
          echo "global property from env: ${env.TEST_VAR}"
          echo "global property: ${TEST_VAR}"
          {code}

          - Build workflow job and go to Console output
          - echo "JOB_NAME from env: ${env.JOB_NAME}"
                -- WORKS: it prints the name of the workflow job
          - {noformat}echo "global property from env: ${env.TEST_VAR}"{noformat}

                -- DOES NOT WORK: ${env.TEST_VAR} evaluates to null
          - echo "global property: ${TEST_VAR}"
                -- ERRORS:

          {code:java}
          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)

          {code}


           
          saan800 Sandra Greenhalgh made changes -
          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"
          - select "Workflow" job type
          - under the "Workflow" heading
             -- Definition: "Groovy CPS DSL"
             -- Script:


          {code:java}
          echo "JOB_NAME from env: ${env.JOB_NAME}"
          echo "global property from env: ${env.TEST_VAR}"
          echo "global property: ${TEST_VAR}"
          {code}

          - Build workflow job and go to Console output
          - echo "JOB_NAME from env: ${env.JOB_NAME}"
                -- WORKS: it prints the name of the workflow job
          - {noformat}echo "global property from env: ${env.TEST_VAR}"{noformat}

                -- DOES NOT WORK: ${env.TEST_VAR} evaluates to null
          - echo "global property: ${TEST_VAR}"
                -- ERRORS:

          {code:java}
          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)

          {code}


           
          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:

          {code:java}
          echo "JOB_NAME from env: ${env.JOB_NAME}"
          echo "global property from env: ${env.TEST_VAR}"
          echo "global property: ${TEST_VAR}"
          {code}

          - Build workflow job and go to Console output
          - from the output can see that the above script evaluates to:

          {code:java}
          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" (not worked, 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)

          {code}


           
          saan800 Sandra Greenhalgh made changes -
          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:

          {code:java}
          echo "JOB_NAME from env: ${env.JOB_NAME}"
          echo "global property from env: ${env.TEST_VAR}"
          echo "global property: ${TEST_VAR}"
          {code}

          - Build workflow job and go to Console output
          - from the output can see that the above script evaluates to:

          {code:java}
          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" (not worked, 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)

          {code}


           
          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:

          {code:java}
          echo "JOB_NAME from env: ${env.JOB_NAME}"
          echo "global property from env: ${env.TEST_VAR}"
          echo "global property: ${TEST_VAR}"
          {code}


          Build workflow job and go to Console output
          from the output can see that the above script evaluates to:

          {code:java}
          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" (not worked, 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)

          {code}


           
          saan800 Sandra Greenhalgh made changes -
          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:

          {code:java}
          echo "JOB_NAME from env: ${env.JOB_NAME}"
          echo "global property from env: ${env.TEST_VAR}"
          echo "global property: ${TEST_VAR}"
          {code}


          Build workflow job and go to Console output
          from the output can see that the above script evaluates to:

          {code:java}
          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" (not worked, 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)

          {code}


           
          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:

          {code:java}
          echo "JOB_NAME from env: ${env.JOB_NAME}"
          echo "global property from env: ${env.TEST_VAR}"
          echo "global property: ${TEST_VAR}"
          {code}


          Build workflow job and go to Console output
          from the output can see that the above script evaluates to:

          {code:java}
          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)

          {code}


           
          jglick Jesse Glick made changes -
          Resolution Not A Defect [ 7 ]
          Status Open [ 1 ] Resolved [ 5 ]
          rtyler R. Tyler Croy made changes -
          Workflow JNJira [ 163785 ] JNJira + In-Review [ 197317 ]
          abayer Andrew Bayer made changes -
          Component/s pipeline-general [ 21692 ]
          abayer Andrew Bayer made changes -
          Component/s workflow-plugin [ 18820 ]
          morgan_goose Morgan Goose made changes -
          Resolution Not A Defect [ 7 ]
          Status Resolved [ 5 ] Reopened [ 4 ]
          deepchip Martin d'Anjou made changes -
          Assignee Jesse Glick [ jglick ] Martin d'Anjou [ deepchip ]
          deepchip Martin d'Anjou made changes -
          Assignee Martin d'Anjou [ deepchip ] Jesse Glick [ jglick ]
          deepchip Martin d'Anjou made changes -
          Summary Can't access Jenkins Global Properties from groovy script Can't access Jenkins Global Properties from Pipeline DSL

          People

            jglick Jesse Glick
            saan800 Sandra Greenhalgh
            Votes:
            2 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated: