Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inject same env variables when building container and exec command #40

Closed
wants to merge 1 commit into from

Conversation

tcollignon
Copy link
Contributor

Hi

Like it said in https://issues.jenkins-ci.org/browse/JENKINS-32393, the injection of environment variables like JAVA_HOME or PATH in the container making trouble, and are not IMO in the feeling of the container way.
Moreover, I see that you have still changed this when the container start here : 79e47f5

I think this is the same when executing each command.
This PR do that.

But maybe you will think that add get/set in BuiltInContainer.java is not the right way to do that, so it's the "facility way", I can change this if you have a better implementation in mind (I'm pretty sure of that).

@jenkinsadmin
Copy link
Member

Thank you for this pull request! Please check this document for how the Jenkins project handles pull requests.

@ndeloof
Copy link
Contributor

ndeloof commented Feb 17, 2016

The intent on rebuilding buildContainerEnvironment is to let buildwrappers introduce additional environment variables into the container, so can't be cached in BuiltInContainer as suggested.

@ndeloof ndeloof closed this Feb 17, 2016
@tcollignon
Copy link
Contributor Author

Thank you for your answer.
So It's another way to not given all env variables (like JAVA_HOME, PATH) into the container? Add a list in a parameter of the plugin in the job ? Or global master list?

@ndeloof
Copy link
Contributor

ndeloof commented Feb 22, 2016

yes, letting Jenkins component inject environment variable but keeping isolation from host executor is not trivial. Using a whitelist would just be a crappy workaround, I'm looking at a global fix

@tcollignon
Copy link
Contributor Author

ok thank you for keeping that problem in mind, if I can help, tell me

@jivk
Copy link

jivk commented Sep 30, 2016

I'm being affected by this issue too. My build job runs the following docker exec command:

docker exec --tty 875fb3f6e0d2f807ee686a45cd7ca454b3e2d21267e69f4904dfc47ee4e4f36a env
[build-java] $ docker exec --tty --user 996:994 875fb3f6e0d2f807ee686a45cd7ca454b3e2d21267e69f4904dfc47ee4e4f36a env BUILD_DISPLAY_NAME=#48 BUILD_ID=48 BUILD_NUMBER=48 BUILD_TAG=jenkins-build-java-48 BUILD_URL=http://167.114.5.144:8080/job/build-java/48/ CLASSPATH= EXECUTOR_NUMBER=1 GIT_BRANCH=origin/develop GIT_COMMIT=ac25cd160339bc918454bdf03b8536e3bad38bd9 GIT_PREVIOUS_COMMIT=ac25cd160339bc918454bdf03b8536e3bad38bd9 GIT_PREVIOUS_SUCCESSFUL_COMMIT=7627d61db1210a0c0e782b3f3b8d738dc09c3cca GIT_URL=[email protected]:truetrademarkets/build-java.git HOME=/root HOSTNAME=875fb3f6e0d2 HUDSON_HOME=/var/lib/jenkins HUDSON_SERVER_COOKIE=9cace0193314c24d HUDSON_URL=http://167.114.5.144:8080/ JENKINS_HOME=/var/lib/jenkins JENKINS_SERVER_COOKIE=9cace0193314c24d JENKINS_URL=http://167.114.5.144:8080/ JOB_BASE_NAME=build-java JOB_NAME=build-java JOB_URL=http://167.114.5.144:8080/job/build-java/ NODE_LABELS=master NODE_NAME=master PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin TERM=xterm WORKSPACE=/var/lib/jenkins/workspace/build-java /var/lib/jenkins/workspace/build-java/gradlew -g /var/lib/jenkins/jenkins-build-java-48 --console=plain --debug clean build

Note the parts in Bold are conflicting - why is the plugin setting $HOME variable to /root
This build command will be executed as user 996 (jenkins user) inside the container.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants