withEnv hangs when overwriting cleared PATH variable

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

XMLWordPrintable

      I want to reset a modified PATH environment variable before modifying it again.

      This pipeline hangs indefinitely in/before the sh step:

       pipeline {
          agent any
          environment {
              // Not necessary for reproduction
              // PATH = "bar:$PATH"
          }
          stages {
              stage('withEnv') {
                  steps {
                      withEnv(['PATH=', 'PATH+FOO=foo']) {
                          sh 'echo $PATH'
                      }
                  }
              }
          }
      }

      Eventually the pipeline is killed with

      process apparently never started in ..../jenkins/workspace/withEnv-test_tmp/durable-89999c02
      (running Jenkins temporarily with -Dorg.jenkinsci.plugins.durabletask.BourneShellScript.LAUNCH_DIAGNOSTICS=true might make the problem clearer)

      The same problem occurs with nesting withEnv blocks or e.g. with a stage environment overwriting a parent environment or even when using keepEnv([]){withEnv(...)}

      Doesn't occur when overwriting a random, non-system variable.

            Assignee:
            Unassigned
            Reporter:
            Yoerg
            Archiver:
            Jenkins Service Account

              Created:
              Updated:
              Archived: