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

PATH and HOME are being overwritten when executing command

      when using the docker-custom-build-environment plugin, when it executes a bash script, it overwrites the PATH in the container with the PATH from the host.

      eg:

      08:57:37 [docker-ec2-cloud] $ docker exec --tty --user 1000: 2bd008eb80469148feb0bb3c6095e2731a755385abbedf0262f74b33f3cb46e9 env ... PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games PWD=/home/ubuntu HOME=/home/ubuntu ... /bin/bash /tmp/hudson4321343385196666792.sh
      

      For reference, when I pull the envs from the container running locally, i get this back for path and home

      PATH=/usr/local/bundle/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
      HOME=/root
      

      I don't think that it should include PATH or HOME, much like how JENKINS-30113 excluded path, but for some reason this was left in here.

          [JENKINS-32393] PATH and HOME are being overwritten when executing command

          Jon Whitcraft created issue -
          Jon Whitcraft made changes -
          Description Original: when using the docker-custom-build-environment plugin, when it executes a bash script, it overwrites the PATH in the container with the PATH from the host.

          eg:

          {code}
          08:57:37 [docker-ec2-cloud] $ docker exec --tty --user 1000: 2bd008eb80469148feb0bb3c6095e2731a755385abbedf0262f74b33f3cb46e9 env .. PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games PWD=/home/ubuntu ... /bin/bash /tmp/hudson4321343385196666792.sh
          {code}

          I don't think that it should include PATH, much like how JENKINS-30113 excluded path, but for some reason this was left [in here|https://github.com/jenkinsci/docker-custom-build-environment-plugin/blame/master/src/main/java/com/cloudbees/jenkins/plugins/docker_build_env/DockerDecoratedLauncher.java#L63].
          New: when using the docker-custom-build-environment plugin, when it executes a bash script, it overwrites the PATH in the container with the PATH from the host.

          eg:

          {code}
          08:57:37 [docker-ec2-cloud] $ docker exec --tty --user 1000: 2bd008eb80469148feb0bb3c6095e2731a755385abbedf0262f74b33f3cb46e9 env ... PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games PWD=/home/ubuntu ... /bin/bash /tmp/hudson4321343385196666792.sh
          {code}

          I don't think that it should include PATH, much like how JENKINS-30113 excluded path, but for some reason this was left [in here|https://github.com/jenkinsci/docker-custom-build-environment-plugin/blame/master/src/main/java/com/cloudbees/jenkins/plugins/docker_build_env/DockerDecoratedLauncher.java#L63].
          Jon Whitcraft made changes -
          Description Original: when using the docker-custom-build-environment plugin, when it executes a bash script, it overwrites the PATH in the container with the PATH from the host.

          eg:

          {code}
          08:57:37 [docker-ec2-cloud] $ docker exec --tty --user 1000: 2bd008eb80469148feb0bb3c6095e2731a755385abbedf0262f74b33f3cb46e9 env ... PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games PWD=/home/ubuntu ... /bin/bash /tmp/hudson4321343385196666792.sh
          {code}

          I don't think that it should include PATH, much like how JENKINS-30113 excluded path, but for some reason this was left [in here|https://github.com/jenkinsci/docker-custom-build-environment-plugin/blame/master/src/main/java/com/cloudbees/jenkins/plugins/docker_build_env/DockerDecoratedLauncher.java#L63].
          New: when using the docker-custom-build-environment plugin, when it executes a bash script, it overwrites the PATH in the container with the PATH from the host.

          eg:

          {code}
          08:57:37 [docker-ec2-cloud] $ docker exec --tty --user 1000: 2bd008eb80469148feb0bb3c6095e2731a755385abbedf0262f74b33f3cb46e9 env ... PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games PWD=/home/ubuntu ... /bin/bash /tmp/hudson4321343385196666792.sh
          {code}

          For reference, when I pull the envs from the container running locally, i get this back for path
          {{code}}
          PATH=/usr/local/bundle/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
          {{code}}

          I don't think that it should include PATH, much like how JENKINS-30113 excluded path, but for some reason this was left [in here|https://github.com/jenkinsci/docker-custom-build-environment-plugin/blame/master/src/main/java/com/cloudbees/jenkins/plugins/docker_build_env/DockerDecoratedLauncher.java#L63].
          Jon Whitcraft made changes -
          Description Original: when using the docker-custom-build-environment plugin, when it executes a bash script, it overwrites the PATH in the container with the PATH from the host.

          eg:

          {code}
          08:57:37 [docker-ec2-cloud] $ docker exec --tty --user 1000: 2bd008eb80469148feb0bb3c6095e2731a755385abbedf0262f74b33f3cb46e9 env ... PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games PWD=/home/ubuntu ... /bin/bash /tmp/hudson4321343385196666792.sh
          {code}

          For reference, when I pull the envs from the container running locally, i get this back for path
          {{code}}
          PATH=/usr/local/bundle/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
          {{code}}

          I don't think that it should include PATH, much like how JENKINS-30113 excluded path, but for some reason this was left [in here|https://github.com/jenkinsci/docker-custom-build-environment-plugin/blame/master/src/main/java/com/cloudbees/jenkins/plugins/docker_build_env/DockerDecoratedLauncher.java#L63].
          New: when using the docker-custom-build-environment plugin, when it executes a bash script, it overwrites the PATH in the container with the PATH from the host.

          eg:

          {code}
          08:57:37 [docker-ec2-cloud] $ docker exec --tty --user 1000: 2bd008eb80469148feb0bb3c6095e2731a755385abbedf0262f74b33f3cb46e9 env ... PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games PWD=/home/ubuntu ... /bin/bash /tmp/hudson4321343385196666792.sh
          {code}

          For reference, when I pull the envs from the container running locally, i get this back for path
          {code}
          PATH=/usr/local/bundle/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
          {code}

          I don't think that it should include PATH, much like how JENKINS-30113 excluded path, but for some reason this was left [in here|https://github.com/jenkinsci/docker-custom-build-environment-plugin/blame/master/src/main/java/com/cloudbees/jenkins/plugins/docker_build_env/DockerDecoratedLauncher.java#L63].
          Jon Whitcraft made changes -
          Summary Original: PATH is being overwritten when executing command New: PATH and HOME are being overwritten when executing command
          Jon Whitcraft made changes -
          Description Original: when using the docker-custom-build-environment plugin, when it executes a bash script, it overwrites the PATH in the container with the PATH from the host.

          eg:

          {code}
          08:57:37 [docker-ec2-cloud] $ docker exec --tty --user 1000: 2bd008eb80469148feb0bb3c6095e2731a755385abbedf0262f74b33f3cb46e9 env ... PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games PWD=/home/ubuntu ... /bin/bash /tmp/hudson4321343385196666792.sh
          {code}

          For reference, when I pull the envs from the container running locally, i get this back for path
          {code}
          PATH=/usr/local/bundle/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
          {code}

          I don't think that it should include PATH, much like how JENKINS-30113 excluded path, but for some reason this was left [in here|https://github.com/jenkinsci/docker-custom-build-environment-plugin/blame/master/src/main/java/com/cloudbees/jenkins/plugins/docker_build_env/DockerDecoratedLauncher.java#L63].
          New: when using the docker-custom-build-environment plugin, when it executes a bash script, it overwrites the PATH in the container with the PATH from the host.

          eg:

          {code}
          08:57:37 [docker-ec2-cloud] $ docker exec --tty --user 1000: 2bd008eb80469148feb0bb3c6095e2731a755385abbedf0262f74b33f3cb46e9 env ... PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games PWD=/home/ubuntu HOME=/home/ubuntu ... /bin/bash /tmp/hudson4321343385196666792.sh
          {code}

          For reference, when I pull the envs from the container running locally, i get this back for path
          {code}
          PATH=/usr/local/bundle/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
          {code}

          I don't think that it should include PATH, much like how JENKINS-30113 excluded path, but for some reason this was left [in here|https://github.com/jenkinsci/docker-custom-build-environment-plugin/blame/master/src/main/java/com/cloudbees/jenkins/plugins/docker_build_env/DockerDecoratedLauncher.java#L63].
          Jon Whitcraft made changes -
          Description Original: when using the docker-custom-build-environment plugin, when it executes a bash script, it overwrites the PATH in the container with the PATH from the host.

          eg:

          {code}
          08:57:37 [docker-ec2-cloud] $ docker exec --tty --user 1000: 2bd008eb80469148feb0bb3c6095e2731a755385abbedf0262f74b33f3cb46e9 env ... PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games PWD=/home/ubuntu HOME=/home/ubuntu ... /bin/bash /tmp/hudson4321343385196666792.sh
          {code}

          For reference, when I pull the envs from the container running locally, i get this back for path
          {code}
          PATH=/usr/local/bundle/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
          {code}

          I don't think that it should include PATH, much like how JENKINS-30113 excluded path, but for some reason this was left [in here|https://github.com/jenkinsci/docker-custom-build-environment-plugin/blame/master/src/main/java/com/cloudbees/jenkins/plugins/docker_build_env/DockerDecoratedLauncher.java#L63].
          New: when using the docker-custom-build-environment plugin, when it executes a bash script, it overwrites the PATH in the container with the PATH from the host.

          eg:

          {code}
          08:57:37 [docker-ec2-cloud] $ docker exec --tty --user 1000: 2bd008eb80469148feb0bb3c6095e2731a755385abbedf0262f74b33f3cb46e9 env ... PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games PWD=/home/ubuntu HOME=/home/ubuntu ... /bin/bash /tmp/hudson4321343385196666792.sh
          {code}

          For reference, when I pull the envs from the container running locally, i get this back for path and home
          {code}
          PATH=/usr/local/bundle/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
          HOME=/root
          {code}

          I don't think that it should include PATH or HOME, much like how JENKINS-30113 excluded path, but for some reason this was left [in here|https://github.com/jenkinsci/docker-custom-build-environment-plugin/blame/master/src/main/java/com/cloudbees/jenkins/plugins/docker_build_env/DockerDecoratedLauncher.java#L63].

          Sylvie Carrier added a comment - - edited

          Hye,
          Same observation when building a maven project. The PATH expected and defined in the Dockerfile (through ENV command) is overwritten by the env ... PATH:... set in the docker exec command (Master configuration) => compilation failed with "java : not found" because PATH no more correct. Moreover, the PATH variable injected in the container is resolved on the Docker host and not in the container (ex: "PATH=$JAVA_HOME/bin:$PATH") whereas injection could be correct if the JAVA_HOME was passed to the container in order to be resoled in it and not on the Docker host. Perhaps escaping the $VAR could be a solution..But it would be nice to have a parameter in the plugin to "Inject master env PATH and Tools" or not.

          Sylvie Carrier added a comment - - edited Hye, Same observation when building a maven project. The PATH expected and defined in the Dockerfile (through ENV command) is overwritten by the env ... PATH:... set in the docker exec command (Master configuration) => compilation failed with "java : not found" because PATH no more correct. Moreover, the PATH variable injected in the container is resolved on the Docker host and not in the container (ex: "PATH=$JAVA_HOME/bin:$PATH") whereas injection could be correct if the JAVA_HOME was passed to the container in order to be resoled in it and not on the Docker host. Perhaps escaping the $VAR could be a solution..But it would be nice to have a parameter in the plugin to "Inject master env PATH and Tools" or not.

          Hi, I have started a PR to fix this : https://github.com/jenkinsci/docker-custom-build-environment-plugin/pull/40

          I think it's just a beginning, but you can try it, and give your feelings.

          Thanks

          Thomas Collignon added a comment - Hi, I have started a PR to fix this : https://github.com/jenkinsci/docker-custom-build-environment-plugin/pull/40 I think it's just a beginning, but you can try it, and give your feelings. Thanks
          Nicolas De Loof made changes -
          Remote Link New: This issue links to "PR (Web Link)" [ 14008 ]

            Unassigned Unassigned
            jwhitcraft Jon Whitcraft
            Votes:
            10 Vote for this issue
            Watchers:
            12 Start watching this issue

              Created:
              Updated: