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

withEnv PATH+ syntax doesn't work in docker.image

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Blocker Blocker
    • docker-plugin, pipeline
    • None
    • Jenkins 2.121.2

      I'm noticing  different behavior after upgrading from Jenkins 1.x to 2.121.2 in how PATH is set.   The withEnv pipeline step includes a special syntax of PATH+ which will update the PATH.  However, this is no longer setting the PATH when nested under the Docker Pipeline docker.image

      In the example below, $MYAPP is available on the output under the PATH var in both nodes below in version 1.642.4.  However, $MYAPP is not set in the PATH output on the node using the docker.image step on Jenkins 2.121.2

       

       

      //ADDS $MYAPP to $PATH
      node {
       withEnv(["PATH+MYAPP=/path/to/myapp/bin"]) {
         stage('Test') {
           sh 'printenv | sort'
         }
        }
      }
      //DOESN'T ADD $MYAPP to $PATH
      node {
       docker.image('bash:latest').inside {
         withEnv(["PATH+MYAPP=/path/to/myapp/bin"]) {
           stage('Test') {
             sh 'printenv | sort'
           }
          }
        }
      }
      

       

       

          [JENKINS-53025] withEnv PATH+ syntax doesn't work in docker.image

          Matt Evans created issue -
          Matt Evans made changes -
          Description Original: Noticing some different behavior after upgrading from Jenkins 1.x to 2.121.2.   It appears the \{{PATH+} syntax from the {{withEnv}}}} pipeline step is no longer setting the PATH in a docker image

           

           
          {code:java}
          //ADDS $MYAPP to $PATH
          node {
           withEnv(["TESTPATH=path/to/test", "PATH+MYAPP=/path/to/myapp/bin"]) {
           stage('Test') {
           sh 'printenv | sort'
           }
           }
          }
          //DOESN'T ADD $MYAPP to $PATH
          node {
           docker.image('bash:latest').inside {
           withEnv(["TESTPATH=path/to/test", "PATH+MYAPP=/path/to/myapp/bin"]) {
           stage('Test') {
           sh 'printenv | sort'
           }
           }
           }
          }
          {code}
           

           
          New: Noticing some different behavior after upgrading from Jenkins 1.x to 2.121.2.   It appears the {{PATH+}}

          syntax from the {{{{withEnv}}}} pipeline step is no longer setting the PATH in a docker image

           

           
          {code:java}
          //ADDS $MYAPP to $PATH
          node {
           withEnv(["TESTPATH=path/to/test", "PATH+MYAPP=/path/to/myapp/bin"]) {
             stage('Test') {
               sh 'printenv | sort'
             }
            }
          }
          //DOESN'T ADD $MYAPP to $PATH
          node {
           docker.image('bash:latest').inside {
             withEnv(["TESTPATH=path/to/test", "PATH+MYAPP=/path/to/myapp/bin"]) {
               stage('Test') {
                 sh 'printenv | sort'
               }
              }
            }
          }
          {code}
           

           
          Matt Evans made changes -
          Description Original: Noticing some different behavior after upgrading from Jenkins 1.x to 2.121.2.   It appears the {{PATH+}}

          syntax from the {{{{withEnv}}}} pipeline step is no longer setting the PATH in a docker image

           

           
          {code:java}
          //ADDS $MYAPP to $PATH
          node {
           withEnv(["TESTPATH=path/to/test", "PATH+MYAPP=/path/to/myapp/bin"]) {
             stage('Test') {
               sh 'printenv | sort'
             }
            }
          }
          //DOESN'T ADD $MYAPP to $PATH
          node {
           docker.image('bash:latest').inside {
             withEnv(["TESTPATH=path/to/test", "PATH+MYAPP=/path/to/myapp/bin"]) {
               stage('Test') {
                 sh 'printenv | sort'
               }
              }
            }
          }
          {code}
           

           
          New: Noticing some different behavior after upgrading from Jenkins 1.x to 2.121.2.   It appears the {{PATH+}}

          syntax from the {{withEnv}} pipeline step is no longer setting the PATH in a docker image

           

           
          {code:java}
          //ADDS $MYAPP to $PATH
          node {
           withEnv(["TESTPATH=path/to/test", "PATH+MYAPP=/path/to/myapp/bin"]) {
             stage('Test') {
               sh 'printenv | sort'
             }
            }
          }
          //DOESN'T ADD $MYAPP to $PATH
          node {
           docker.image('bash:latest').inside {
             withEnv(["TESTPATH=path/to/test", "PATH+MYAPP=/path/to/myapp/bin"]) {
               stage('Test') {
                 sh 'printenv | sort'
               }
              }
            }
          }
          {code}
           

           
          Matt Evans made changes -
          Description Original: Noticing some different behavior after upgrading from Jenkins 1.x to 2.121.2.   It appears the {{PATH+}}

          syntax from the {{withEnv}} pipeline step is no longer setting the PATH in a docker image

           

           
          {code:java}
          //ADDS $MYAPP to $PATH
          node {
           withEnv(["TESTPATH=path/to/test", "PATH+MYAPP=/path/to/myapp/bin"]) {
             stage('Test') {
               sh 'printenv | sort'
             }
            }
          }
          //DOESN'T ADD $MYAPP to $PATH
          node {
           docker.image('bash:latest').inside {
             withEnv(["TESTPATH=path/to/test", "PATH+MYAPP=/path/to/myapp/bin"]) {
               stage('Test') {
                 sh 'printenv | sort'
               }
              }
            }
          }
          {code}
           

           
          New: Noticing some different behavior after upgrading from Jenkins 1.x to 2.121.2.   It appears the {{PATH+}}

          syntax from the {{withEnv}} pipeline step is no longer setting the PATH in a docker image

           

           
          {code:java}
          //ADDS $MYAPP to $PATH
          node {
           withEnv(["TESTPATH=path/to/test", "PATH+MYAPP=/path/to/myapp/bin"]) {
             stage('Test') {
               sh 'printenv | sort'
             }
            }
          }
          //DOESN'T ADD $MYAPP to $PATH
          node {
           docker.image('bash:latest').inside {
             withEnv(["TESTPATH=path/to/test", "PATH+MYAPP=/path/to/myapp/bin"]) {
               stage('Test') {
                 sh 'printenv | sort'
               }
              }
            }
          }
          {code}
           

          My old version of Jenkins 1.642.2 adds MYAPP to the PATH in both cases above.  So there is something that has changed since then.

           
          Matt Evans made changes -
          Description Original: Noticing some different behavior after upgrading from Jenkins 1.x to 2.121.2.   It appears the {{PATH+}}

          syntax from the {{withEnv}} pipeline step is no longer setting the PATH in a docker image

           

           
          {code:java}
          //ADDS $MYAPP to $PATH
          node {
           withEnv(["TESTPATH=path/to/test", "PATH+MYAPP=/path/to/myapp/bin"]) {
             stage('Test') {
               sh 'printenv | sort'
             }
            }
          }
          //DOESN'T ADD $MYAPP to $PATH
          node {
           docker.image('bash:latest').inside {
             withEnv(["TESTPATH=path/to/test", "PATH+MYAPP=/path/to/myapp/bin"]) {
               stage('Test') {
                 sh 'printenv | sort'
               }
              }
            }
          }
          {code}
           

          My old version of Jenkins 1.642.2 adds MYAPP to the PATH in both cases above.  So there is something that has changed since then.

           
          New: I'm noticing  different behavior after upgrading from Jenkins 1.x to 2.121.2 in how {{PATH}} is set.   The \{{withEnv]} includes special syntax of *{{PATH+*}} which will update the PATH.  However, this is no longer setting the PATH when nested under the Docker Pipeline {{docker.image}}

          In the example below, {{$MYAPP}} is available on the output under the PATH var in both nodes below.  However, {{$MYAPP}} is not included on the node using the docker.image step on Jenkins 2.121.2

           

           
          {code:java}
          //ADDS $MYAPP to $PATH
          node {
           withEnv(["TESTPATH=path/to/test", "PATH+MYAPP=/path/to/myapp/bin"]) {
             stage('Test') {
               sh 'printenv | sort'
             }
            }
          }
          //DOESN'T ADD $MYAPP to $PATH
          node {
           docker.image('bash:latest').inside {
             withEnv(["TESTPATH=path/to/test", "PATH+MYAPP=/path/to/myapp/bin"]) {
               stage('Test') {
                 sh 'printenv | sort'
               }
              }
            }
          }
          {code}
           

          My old version of Jenkins 1.642.2 adds MYAPP to the PATH in both cases above.  So there is something that has changed since then.

           
          Matt Evans made changes -
          Description Original: I'm noticing  different behavior after upgrading from Jenkins 1.x to 2.121.2 in how {{PATH}} is set.   The \{{withEnv]} includes special syntax of *{{PATH+*}} which will update the PATH.  However, this is no longer setting the PATH when nested under the Docker Pipeline {{docker.image}}

          In the example below, {{$MYAPP}} is available on the output under the PATH var in both nodes below.  However, {{$MYAPP}} is not included on the node using the docker.image step on Jenkins 2.121.2

           

           
          {code:java}
          //ADDS $MYAPP to $PATH
          node {
           withEnv(["TESTPATH=path/to/test", "PATH+MYAPP=/path/to/myapp/bin"]) {
             stage('Test') {
               sh 'printenv | sort'
             }
            }
          }
          //DOESN'T ADD $MYAPP to $PATH
          node {
           docker.image('bash:latest').inside {
             withEnv(["TESTPATH=path/to/test", "PATH+MYAPP=/path/to/myapp/bin"]) {
               stage('Test') {
                 sh 'printenv | sort'
               }
              }
            }
          }
          {code}
           

          My old version of Jenkins 1.642.2 adds MYAPP to the PATH in both cases above.  So there is something that has changed since then.

           
          New: I'm noticing  different behavior after upgrading from Jenkins 1.x to 2.121.2 in how {{PATH}} is set.   The \{{withEnv]}

          includes special syntax of *{{PATH+}}* which will update the PATH.  However, this is no longer setting the PATH when nested under the Docker Pipeline {{docker.image}}

          In the example below, {{$MYAPP}} is available on the output under the PATH var in both nodes below.  However, {{$MYAPP}} is not included on the node using the docker.image step on Jenkins 2.121.2

           

           
          {code:java}
          //ADDS $MYAPP to $PATH
          node {
           withEnv(["TESTPATH=path/to/test", "PATH+MYAPP=/path/to/myapp/bin"]) {
             stage('Test') {
               sh 'printenv | sort'
             }
            }
          }
          //DOESN'T ADD $MYAPP to $PATH
          node {
           docker.image('bash:latest').inside {
             withEnv(["TESTPATH=path/to/test", "PATH+MYAPP=/path/to/myapp/bin"]) {
               stage('Test') {
                 sh 'printenv | sort'
               }
              }
            }
          }
          {code}
           

          My old version of Jenkins 1.642.2 adds MYAPP to the PATH in both cases above.  So there is something that has changed since then.

           
          Matt Evans made changes -
          Description Original: I'm noticing  different behavior after upgrading from Jenkins 1.x to 2.121.2 in how {{PATH}} is set.   The \{{withEnv]}

          includes special syntax of *{{PATH+}}* which will update the PATH.  However, this is no longer setting the PATH when nested under the Docker Pipeline {{docker.image}}

          In the example below, {{$MYAPP}} is available on the output under the PATH var in both nodes below.  However, {{$MYAPP}} is not included on the node using the docker.image step on Jenkins 2.121.2

           

           
          {code:java}
          //ADDS $MYAPP to $PATH
          node {
           withEnv(["TESTPATH=path/to/test", "PATH+MYAPP=/path/to/myapp/bin"]) {
             stage('Test') {
               sh 'printenv | sort'
             }
            }
          }
          //DOESN'T ADD $MYAPP to $PATH
          node {
           docker.image('bash:latest').inside {
             withEnv(["TESTPATH=path/to/test", "PATH+MYAPP=/path/to/myapp/bin"]) {
               stage('Test') {
                 sh 'printenv | sort'
               }
              }
            }
          }
          {code}
           

          My old version of Jenkins 1.642.2 adds MYAPP to the PATH in both cases above.  So there is something that has changed since then.

           
          New: I'm noticing  different behavior after upgrading from Jenkins 1.x to 2.121.2 in how {{PATH}} is set.   The \{{withEnv}}

          includes special syntax of *{{PATH+}}* which will update the PATH.  However, this is no longer setting the PATH when nested under the Docker Pipeline {{docker.image}}

          In the example below, {{$MYAPP}} is available on the output under the PATH var in both nodes below.  However, {{$MYAPP}} is not included on the node using the docker.image step on Jenkins 2.121.2

           

           
          {code:java}
          //ADDS $MYAPP to $PATH
          node {
           withEnv(["TESTPATH=path/to/test", "PATH+MYAPP=/path/to/myapp/bin"]) {
             stage('Test') {
               sh 'printenv | sort'
             }
            }
          }
          //DOESN'T ADD $MYAPP to $PATH
          node {
           docker.image('bash:latest').inside {
             withEnv(["TESTPATH=path/to/test", "PATH+MYAPP=/path/to/myapp/bin"]) {
               stage('Test') {
                 sh 'printenv | sort'
               }
              }
            }
          }
          {code}
           

          My old version of Jenkins 1.642.2 adds MYAPP to the PATH in both cases above.  So there is something that has changed since then.

           
          Matt Evans made changes -
          Description Original: I'm noticing  different behavior after upgrading from Jenkins 1.x to 2.121.2 in how {{PATH}} is set.   The \{{withEnv}}

          includes special syntax of *{{PATH+}}* which will update the PATH.  However, this is no longer setting the PATH when nested under the Docker Pipeline {{docker.image}}

          In the example below, {{$MYAPP}} is available on the output under the PATH var in both nodes below.  However, {{$MYAPP}} is not included on the node using the docker.image step on Jenkins 2.121.2

           

           
          {code:java}
          //ADDS $MYAPP to $PATH
          node {
           withEnv(["TESTPATH=path/to/test", "PATH+MYAPP=/path/to/myapp/bin"]) {
             stage('Test') {
               sh 'printenv | sort'
             }
            }
          }
          //DOESN'T ADD $MYAPP to $PATH
          node {
           docker.image('bash:latest').inside {
             withEnv(["TESTPATH=path/to/test", "PATH+MYAPP=/path/to/myapp/bin"]) {
               stage('Test') {
                 sh 'printenv | sort'
               }
              }
            }
          }
          {code}
           

          My old version of Jenkins 1.642.2 adds MYAPP to the PATH in both cases above.  So there is something that has changed since then.

           
          New: I'm noticing  different behavior after upgrading from Jenkins 1.x to 2.121.2 in how {{PATH}} is set.   The {{withEnv }}pipeline step includes a special syntax of *{{PATH+}}* which will update the PATH.  However, this is no longer setting the PATH when nested under the Docker Pipeline {{docker.image}}

          In the example below, {{$MYAPP}} is available on the output under the PATH var in both nodes below.  However, {{$MYAPP}} is not included on the node using the docker.image step on Jenkins 2.121.2

           

           
          {code:java}
          //ADDS $MYAPP to $PATH
          node {
           withEnv(["TESTPATH=path/to/test", "PATH+MYAPP=/path/to/myapp/bin"]) {
             stage('Test') {
               sh 'printenv | sort'
             }
            }
          }
          //DOESN'T ADD $MYAPP to $PATH
          node {
           docker.image('bash:latest').inside {
             withEnv(["TESTPATH=path/to/test", "PATH+MYAPP=/path/to/myapp/bin"]) {
               stage('Test') {
                 sh 'printenv | sort'
               }
              }
            }
          }
          {code}
           

          My old version of Jenkins 1.642.2 adds MYAPP to the PATH in both cases above.  So there is something that has changed since then.

           
          Matt Evans made changes -
          Description Original: I'm noticing  different behavior after upgrading from Jenkins 1.x to 2.121.2 in how {{PATH}} is set.   The {{withEnv }}pipeline step includes a special syntax of *{{PATH+}}* which will update the PATH.  However, this is no longer setting the PATH when nested under the Docker Pipeline {{docker.image}}

          In the example below, {{$MYAPP}} is available on the output under the PATH var in both nodes below.  However, {{$MYAPP}} is not included on the node using the docker.image step on Jenkins 2.121.2

           

           
          {code:java}
          //ADDS $MYAPP to $PATH
          node {
           withEnv(["TESTPATH=path/to/test", "PATH+MYAPP=/path/to/myapp/bin"]) {
             stage('Test') {
               sh 'printenv | sort'
             }
            }
          }
          //DOESN'T ADD $MYAPP to $PATH
          node {
           docker.image('bash:latest').inside {
             withEnv(["TESTPATH=path/to/test", "PATH+MYAPP=/path/to/myapp/bin"]) {
               stage('Test') {
                 sh 'printenv | sort'
               }
              }
            }
          }
          {code}
           

          My old version of Jenkins 1.642.2 adds MYAPP to the PATH in both cases above.  So there is something that has changed since then.

           
          New: I'm noticing  different behavior after upgrading from Jenkins 1.x to 2.121.2 in how {{PATH}} is set.   The {{withEnv }}pipeline step includes a special syntax of *PATH+*}} which will update the PATH.  However, this is no longer setting the PATH when nested under the Docker Pipeline {{docker.image}}

          In the example below, {{$MYAPP}} is available on the output under the PATH var in both nodes below.  However, {{$MYAPP}} is not included on the node using the docker.image step on Jenkins 2.121.2

           

           
          {code:java}
          //ADDS $MYAPP to $PATH
          node {
           withEnv(["TESTPATH=path/to/test", "PATH+MYAPP=/path/to/myapp/bin"]) {
             stage('Test') {
               sh 'printenv | sort'
             }
            }
          }
          //DOESN'T ADD $MYAPP to $PATH
          node {
           docker.image('bash:latest').inside {
             withEnv(["TESTPATH=path/to/test", "PATH+MYAPP=/path/to/myapp/bin"]) {
               stage('Test') {
                 sh 'printenv | sort'
               }
              }
            }
          }
          {code}
           

          My old version of Jenkins 1.642.2 adds MYAPP to the PATH in both cases above.  So there is something that has changed since then.

           
          Matt Evans made changes -
          Description Original: I'm noticing  different behavior after upgrading from Jenkins 1.x to 2.121.2 in how {{PATH}} is set.   The {{withEnv }}pipeline step includes a special syntax of *PATH+*}} which will update the PATH.  However, this is no longer setting the PATH when nested under the Docker Pipeline {{docker.image}}

          In the example below, {{$MYAPP}} is available on the output under the PATH var in both nodes below.  However, {{$MYAPP}} is not included on the node using the docker.image step on Jenkins 2.121.2

           

           
          {code:java}
          //ADDS $MYAPP to $PATH
          node {
           withEnv(["TESTPATH=path/to/test", "PATH+MYAPP=/path/to/myapp/bin"]) {
             stage('Test') {
               sh 'printenv | sort'
             }
            }
          }
          //DOESN'T ADD $MYAPP to $PATH
          node {
           docker.image('bash:latest').inside {
             withEnv(["TESTPATH=path/to/test", "PATH+MYAPP=/path/to/myapp/bin"]) {
               stage('Test') {
                 sh 'printenv | sort'
               }
              }
            }
          }
          {code}
           

          My old version of Jenkins 1.642.2 adds MYAPP to the PATH in both cases above.  So there is something that has changed since then.

           
          New: I'm noticing  different behavior after upgrading from Jenkins 1.x to 2.121.2 in how {{PATH}} is set.   The {{withEnv }}pipeline step{{ }}includes a special syntax of{{ *PATH+*}} which will update the PATH.  However, this is no longer setting the PATH when nested under the Docker Pipeline {{docker.image}}

          In the example below, {{$MYAPP}} is available on the output under the PATH var in both nodes below.  However, {{$MYAPP}} is not included on the node using the docker.image step on Jenkins 2.121.2

           

           
          {code:java}
          //ADDS $MYAPP to $PATH
          node {
           withEnv(["TESTPATH=path/to/test", "PATH+MYAPP=/path/to/myapp/bin"]) {
             stage('Test') {
               sh 'printenv | sort'
             }
            }
          }
          //DOESN'T ADD $MYAPP to $PATH
          node {
           docker.image('bash:latest').inside {
             withEnv(["TESTPATH=path/to/test", "PATH+MYAPP=/path/to/myapp/bin"]) {
               stage('Test') {
                 sh 'printenv | sort'
               }
              }
            }
          }
          {code}
           

          My old version of Jenkins 1.642.2 adds MYAPP to the PATH in both cases above.  So there is something that has changed since then.

           
          Matt Evans made changes -
          Description Original: I'm noticing  different behavior after upgrading from Jenkins 1.x to 2.121.2 in how {{PATH}} is set.   The {{withEnv }}pipeline step{{ }}includes a special syntax of{{ *PATH+*}} which will update the PATH.  However, this is no longer setting the PATH when nested under the Docker Pipeline {{docker.image}}

          In the example below, {{$MYAPP}} is available on the output under the PATH var in both nodes below.  However, {{$MYAPP}} is not included on the node using the docker.image step on Jenkins 2.121.2

           

           
          {code:java}
          //ADDS $MYAPP to $PATH
          node {
           withEnv(["TESTPATH=path/to/test", "PATH+MYAPP=/path/to/myapp/bin"]) {
             stage('Test') {
               sh 'printenv | sort'
             }
            }
          }
          //DOESN'T ADD $MYAPP to $PATH
          node {
           docker.image('bash:latest').inside {
             withEnv(["TESTPATH=path/to/test", "PATH+MYAPP=/path/to/myapp/bin"]) {
               stage('Test') {
                 sh 'printenv | sort'
               }
              }
            }
          }
          {code}
           

          My old version of Jenkins 1.642.2 adds MYAPP to the PATH in both cases above.  So there is something that has changed since then.

           
          New: I'm noticing  different behavior after upgrading from Jenkins 1.x to 2.121.2 in how {{PATH}} is set.   The {{withEnv}} pipeline step includes a special syntax of *PATH+* which will update the PATH.  However, this is no longer setting the PATH when nested under the Docker Pipeline {{docker.image}}

          In the example below, {{$MYAPP}} is available on the output under the PATH var in both nodes below.  However, {{$MYAPP}} is not included on the node using the docker.image step on Jenkins 2.121.2

           

           
          {code:java}
          //ADDS $MYAPP to $PATH
          node {
           withEnv(["TESTPATH=path/to/test", "PATH+MYAPP=/path/to/myapp/bin"]) {
             stage('Test') {
               sh 'printenv | sort'
             }
            }
          }
          //DOESN'T ADD $MYAPP to $PATH
          node {
           docker.image('bash:latest').inside {
             withEnv(["TESTPATH=path/to/test", "PATH+MYAPP=/path/to/myapp/bin"]) {
               stage('Test') {
                 sh 'printenv | sort'
               }
              }
            }
          }
          {code}
           

          My old version of Jenkins 1.642.2 adds MYAPP to the PATH in both cases above.  So there is something that has changed since then.

           

            ndeloof Nicolas De Loof
            mevans Matt Evans
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: