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

withEnv hangs when overwriting cleared PATH variable

    • 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.

          [JENKINS-73727] withEnv hangs when overwriting cleared PATH variable

          Yoerg created issue -
          Yoerg made changes -
          Description Original: I want to reset a modified {{PATH}} environment variable before modifying it again.

          This pipeline hangs indefinitely in/before the {{sh}} step:
          {code:groovy}
           pipeline {
              agent any
              environment {
                  // Not necessary for reproduction
                  // PATH = "bar:$PATH"
              }
              stages {
                  stage('withEnv') {
                      steps {
                          withEnv(['PATH=', 'PATH+FOO=foo']) {
                              sh 'echo $PATH'
                          }
                      }
                  }
              }
          }{code}
          Eventually the pipeline is killed with
          {code:java}
          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){code}

          The same problem occurs with nesting {{withEnv}} blocks or e.g. with a stage {{environment}} overwriting a parent {{environment}}.
          New: I want to reset a modified {{PATH}} environment variable before modifying it again.

          This pipeline hangs indefinitely in/before the {{sh}} step:
          {code:groovy}
           pipeline {
              agent any
              environment {
                  // Not necessary for reproduction
                  // PATH = "bar:$PATH"
              }
              stages {
                  stage('withEnv') {
                      steps {
                          withEnv(['PATH=', 'PATH+FOO=foo']) {
                              sh 'echo $PATH'
                          }
                      }
                  }
              }
          }{code}
          Eventually the pipeline is killed with
          {code:java}
          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){code}

          The same problem occurs with nesting {{withEnv}} blocks or e.g. with a stage {{environment}} overwriting a parent {{environment}}.

          Doesn't occur when overwriting a random, non-system variable.
          Yoerg made changes -
          Description Original: I want to reset a modified {{PATH}} environment variable before modifying it again.

          This pipeline hangs indefinitely in/before the {{sh}} step:
          {code:groovy}
           pipeline {
              agent any
              environment {
                  // Not necessary for reproduction
                  // PATH = "bar:$PATH"
              }
              stages {
                  stage('withEnv') {
                      steps {
                          withEnv(['PATH=', 'PATH+FOO=foo']) {
                              sh 'echo $PATH'
                          }
                      }
                  }
              }
          }{code}
          Eventually the pipeline is killed with
          {code:java}
          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){code}

          The same problem occurs with nesting {{withEnv}} blocks or e.g. with a stage {{environment}} overwriting a parent {{environment}}.

          Doesn't occur when overwriting a random, non-system variable.
          New: I want to reset a modified {{PATH}} environment variable before modifying it again.

          This pipeline hangs indefinitely in/before the {{sh}} step:
          {code:groovy}
           pipeline {
              agent any
              environment {
                  // Not necessary for reproduction
                  // PATH = "bar:$PATH"
              }
              stages {
                  stage('withEnv') {
                      steps {
                          withEnv(['PATH=', 'PATH+FOO=foo']) {
                              sh 'echo $PATH'
                          }
                      }
                  }
              }
          }{code}
          Eventually the pipeline is killed with
          {code:java}
          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){code}

          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: