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

withEnv does not support nesting

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • pipeline
    • None
    • Jenkins 1.6.11
      Workflow 1.6

      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.

            jglick Jesse Glick
            sumdumgai A C
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: