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

Reorder environment variables

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      Environment variables can depend on each other, so their ordering matters.

      For example, this makes no sense unless we can reorder these:

      environment  {
           test = "${test2}"
           test2 = "test2"
      }
      

        Attachments

          Issue Links

            Activity

            Hide
            abayer Andrew Bayer added a comment -

            So the ordering of the environment variables doesn't actually matter in practice - we end up resolving the environment variables later using hudson.EnvVars.overrideExpandingAll(Map), which does some nifty magic behind the scenes to figure out the right order to resolve the variables in based on their contents. Is nifty indeed.

            Show
            abayer Andrew Bayer added a comment - So the ordering of the environment variables doesn't actually matter in practice - we end up resolving the environment variables later using hudson.EnvVars.overrideExpandingAll(Map) , which does some nifty magic behind the scenes to figure out the right order to resolve the variables in based on their contents. Is nifty indeed.
            Hide
            jamesdumay James Dumay added a comment -

            This is something we can think about doing when we revisit the environment variable control however the use case isn't particularly strong IMO.

            Show
            jamesdumay James Dumay added a comment - This is something we can think about doing when we revisit the environment variable control however the use case isn't particularly strong IMO.
            Hide
            jamesdumay James Dumay added a comment -

            Liam Newman don't bother assigning these to me - I see everything anyway and its just one more step during triaging to unassign myself

            Show
            jamesdumay James Dumay added a comment - Liam Newman don't bother assigning these to me - I see everything anyway and its just one more step during triaging to unassign myself
            Hide
            bitwiseman Liam Newman added a comment -

            James Dumay I don't think I was assigning them intentionally. I'll double check.

            Andrew Bayer
            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 {
                test = "${test2 + test3}"
                test2 = "value2"
                test3 = "${test2}"
              }
              stages {
                stage('Install') {
                  steps {
                    sh 'echo "${test}"'
                  }
                }
              }
            }
            

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

            Show
            bitwiseman Liam Newman added a comment - James Dumay I don't think I was assigning them intentionally. I'll double check. Andrew Bayer 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 { test = "${test2 + test3}" test2 = "value2" test3 = "${test2}" } stages { stage( 'Install' ) { steps { sh 'echo "${test}" ' } } } } "groovy.lang.MissingPropertyException: No such property: test2 for class: groovy.lang.Binding"
            Hide
            abayer Andrew Bayer added a comment -

            Huh. Interesting. Not 100% sure that'd work if it was in the expected order...it'll definitely resolve any "${foo}" references correctly, but the env var resolution doesn't grok "${test2 + test3}" as env vars, so it doesn't know what to do about them. Open a JIRA for that?

            Show
            abayer Andrew Bayer added a comment - Huh. Interesting. Not 100% sure that'd work if it was in the expected order...it'll definitely resolve any "${foo}" references correctly, but the env var resolution doesn't grok "${test2 + test3}" as env vars, so it doesn't know what to do about them. Open a JIRA for that?

              People

              • Assignee:
                Unassigned
                Reporter:
                bitwiseman Liam Newman
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated: