environment directive doesn't properly order GString evaluation

This issue is archived. You can view it, but you can't modify it. Learn more

XMLWordPrintable

      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.

            Assignee:
            Andrew Bayer
            Reporter:
            Liam Newman
            Archiver:
            Jenkins Service Account

              Created:
              Updated:
              Resolved:
              Archived: