withEnv does not support nesting

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

XMLWordPrintable

      A nested withEnv step clobbers its parent withEnv. Test code:

      withEnv(['FOO=BAR']) {
      echo "${env.FOO}"
      withEnv(['ALICE=BOB']){
      echo "${env.ALICE}"
      echo "${env.FOO}"
      }
      }

      Results in the output:
      BAR
      BOB
      null

      Nested withEnv steps should properly merge and un-merge with their parents. Only workaround appears to be manually managing nested environments. This significantly hobbles the use of withEnv in complex builds.

            Assignee:
            Jesse Glick
            Reporter:
            A C
            Archiver:
            Jenkins Service Account

              Created:
              Updated:
              Resolved:
              Archived: