Force jenkins user on exec commands
replace #130 Allow to specify an different user for the run
docker.image('dummy').inside('-u root:root -e BUILDER_UID=1001 -e BUILDER_GID=1001 -e BUILDER_USER=jenkins -e BUILDER_GROUP=jenkins -e HOME=/home/jenkins) {
}
Will run docker run -t -u 1001:1001 -u root:root ... and docker exec -u 1001:1001 ...
How can this be used with DSL? At the moment we do something like:
agent {
label 'docker'
image 'php:7.1'
}
Obviously we can specify extra args, but will these allow overriding the user in the run stage?
I guess one 'ideal' would be to take a user argument in the agent stanza.
I rebased my PR on master
Does this change break any existing usage? If so then it should be implemented conditionally, based on a new parameter etc.
This is break only the usage when the user force the user as image parameters with -u root:root for example. The current behaviour seems to be an issue for many people currently
Okay, I finally succeeded to test the behaviour.