[JIRA] [docker-custom-build-environment-plugin] (JENKINS-32393) PATH and HOME are being overwritten when executing command

3 views
Skip to first unread message

jwhitcraft@sugarcrm.com (JIRA)

unread,
Jan 11, 2016, 12:35:01 PM1/11/16
to jenkinsc...@googlegroups.com
Jon Whitcraft updated an issue
 
Jenkins / Bug JENKINS-32393
PATH and HOME are being overwritten when executing command
Change By: Jon Whitcraft
Summary: PATH  is  and HOME are  being overwritten when executing command
Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v6.4.2#64017-sha1:e244265)
Atlassian logo

jwhitcraft@sugarcrm.com (JIRA)

unread,
Jan 11, 2016, 12:36:01 PM1/11/16
to jenkinsc...@googlegroups.com
Jon Whitcraft updated an issue
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].

jwhitcraft@sugarcrm.com (JIRA)

unread,
Jan 11, 2016, 12:36:03 PM1/11/16
to jenkinsc...@googlegroups.com
Jon Whitcraft updated an issue
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].

syl.carrier@laposte.net (JIRA)

unread,
Jan 21, 2016, 4:24:01 AM1/21/16
to jenkinsc...@googlegroups.com
Sylvie Carrier commented on Bug JENKINS-32393
 
Re: PATH and HOME are being overwritten when executing command

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 $

{...}

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.

syl.carrier@laposte.net (JIRA)

unread,
Jan 21, 2016, 4:25:01 AM1/21/16
to jenkinsc...@googlegroups.com
Sylvie Carrier edited a comment on Bug JENKINS-32393

syl.carrier@laposte.net (JIRA)

unread,
Jan 21, 2016, 4:25:01 AM1/21/16
to jenkinsc...@googlegroups.com
Sylvie Carrier edited a comment on Bug JENKINS-32393
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.

tomiphone3G@gmail.com (JIRA)

unread,
Jan 30, 2016, 5:08:02 PM1/30/16
to jenkinsc...@googlegroups.com

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.deloof@gmail.com (JIRA)

unread,
Feb 29, 2016, 9:54:03 AM2/29/16
to jenkinsc...@googlegroups.com

philporada@gmail.com (JIRA)

unread,
Nov 14, 2016, 4:47:02 PM11/14/16
to jenkinsc...@googlegroups.com
Phil Porada updated an issue
Change By: Phil Porada
Attachment: workaround.png
This message was sent by Atlassian JIRA (v7.1.7#71011-sha1:2526d7c)
Atlassian logo

philporada@gmail.com (JIRA)

unread,
Nov 14, 2016, 4:47:04 PM11/14/16
to jenkinsc...@googlegroups.com
Phil Porada commented on Bug JENKINS-32393
 
Re: PATH and HOME are being overwritten when executing command

I am experiencing this as well. Here is my current workaround on all jobs that use this plugin.

nicolas.deloof@gmail.com (JIRA)

unread,
Apr 24, 2019, 10:30:21 AM4/24/19
to jenkinsc...@googlegroups.com
Nicolas De Loof assigned an issue to Unassigned
 
Change By: Nicolas De Loof
Assignee: Nicolas De Loof
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

hursh@us.ibm.com (JIRA)

unread,
Jan 28, 2020, 5:01:03 PM1/28/20
to jenkinsc...@googlegroups.com
Daniel Hursh commented on Bug JENKINS-32393
 
Re: PATH and HOME are being overwritten when executing command

I'm hitting this as well. Our images install various tools and define env variables that they need.  Things like JAVA_HOME, JRE_HOME, M2_HOME, ANT_HOME & GRADLE_HOME are all getting clobbered with the values from the docker host.  In addition PATH is getting clobbered.

 

We really need a way to blacklist and / or whitelist variables that are to be passed into the container.  Several of the environment variables set on the host don't make sense for the images we use to build.

This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages