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

environment directive doesn't properly order GString evaluation

    XMLWordPrintable

Details

    Description

      On Declarative 1.1.1, with this Pipeline, I get an error:
      repo: https://github.com/bitwiseman/hermann/
      branch: issue/blue-ocean-editor/env-order

      pipeline {
        agent any
        environment {
          test2 = "value2"
          test3 = "${test2}"
          test = "${test2 + test3}"
        }
        stages {
          stage('Install') {
            steps {
              sh 'echo "${test}"'
            }
          }
        }
      }
      

      "groovy.lang.MissingPropertyException: No such property: test2 for class: groovy.lang.Binding"

      This also errors the same way:

      pipeline {
        agent any
        environment {
          test = "${test2 + test3}"
          test2 = "value2"
          test3 = "${test2}"
        }
        stages {
          stage('Install') {
            steps {
              sh 'echo "${test}"'
            }
          }
        }
      }
      

      I'd expect the second example to error, due to out-of-order assignment. If this too can be fixed, that'd be fine, too. But the simple sequential evaluation of show in the first example should always work.

      Attachments

        Issue Links

          Activity

            bitwiseman Liam Newman created issue -
            bitwiseman Liam Newman made changes -
            Field Original Value New Value
            Link This issue relates to JENKINS-43008 [ JENKINS-43008 ]
            bitwiseman Liam Newman made changes -
            Description On Declarative 1.1.1, with this Pipeline, I get an error:
            repo: https://github.com/bitwiseman/hermann/
            branch: issue/blue-ocean-editor/env-order

            {code}
            pipeline {
              agent any
              environment {
                test2 = "value2"
                test3 = "${test2}"
                test = "${test2 + test3}"
              }
              stages {
                stage('Install') {
                  steps {
                    sh 'echo "${test}"'
                  }
                }
              }
            }
            {code}

            "groovy.lang.MissingPropertyException: No such property: test2 for class: groovy.lang.Binding"

            This also errors the same way:
            {code}
            pipeline {
              agent any
              environment {
                test = "${test2 + test3}"
                test2 = "value2"
                test3 = "${test2}"
              }
              stages {
                stage('Install') {
                  steps {
                    sh 'echo "${test}"'
                  }
                }
              }
            }
            {code}


            I'd expect the second example to error, due to out-of-order assignment. If this too can be fixed, that'd be fine, too. But the simple sequential evaluation of show in the first example should always work.

            abayer Andrew Bayer made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            abayer Andrew Bayer made changes -
            Status In Progress [ 3 ] In Review [ 10005 ]
            abayer Andrew Bayer added a comment -

            This ends up getting pulled along as part of https://github.com/jenkinsci/pipeline-model-definition-plugin/pull/147

            abayer Andrew Bayer added a comment - This ends up getting pulled along as part of  https://github.com/jenkinsci/pipeline-model-definition-plugin/pull/147
            abayer Andrew Bayer made changes -
            Remote Link This issue links to "PR #147 (Web Link)" [ 15826 ]
            abayer Andrew Bayer made changes -
            Resolution Fixed [ 1 ]
            Status In Review [ 10005 ] Resolved [ 5 ]
            bitwiseman Liam Newman added a comment -

            Bulk closing resolved issues.

            bitwiseman Liam Newman added a comment - Bulk closing resolved issues.
            bitwiseman Liam Newman made changes -
            Status Resolved [ 5 ] Closed [ 6 ]

            People

              abayer Andrew Bayer
              bitwiseman Liam Newman
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: