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

withEnv hangs when overwriting cleared PATH variable

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • Jenkins 2.462.2
      java.runtime.name OpenJDK Runtime Environment
      java.runtime.version 21.0.4+7-Ubuntu-1ubuntu222.04

      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.

            Unassigned Unassigned
            yoerg Yoerg
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: