This is by design. If the build process doesn't run as host's user
"jenkins" then this would corrupt the workspace with files one can't
read/delete later
The fact the jenkins user doesn't exists isn't an issue.

You should prepare your docker image so it let arbitrary user create
content under /go/src, or maybe use an alternate GOPATH for this build.

2017-02-16 16:12 GMT+01:00 Tom Lester <t...@tomlester.com>:

> My basic pipeline used to generate this output:
>
> pipeline {
>     agent {
>         docker {
>             image 'maven:3-alpine'
>             args  '-u root'
>         }
>     }
>     stages {
>         stage('Example Build') {
>             steps {
>                 sh 'ps -ef'
>             }
>         }
>     }
> }
>
>
>
> On Thursday, February 16, 2017 at 10:08:44 AM UTC-5, Tom Lester wrote:
>>
>> Hi all -
>>
>> I have a docker host.  Jenkins ssh's (as the user jenkins) to this host
>> via pipeline steps and builds apps inside the specified docker image.  This
>> all pretty much flows as planned.  However... when the pipeline executes a
>> "docker.insdie" or via pipeline -> agent -> docker, the docker image is
>> always launched as the jenkins user.   Even if I specify "-u root" in the
>> option, it's still has the "-u 501" which is the jenkins user.
>>
>> How can I get around this?   My build steps requires me to be able to
>> create a /go/src/<etc> directory and the jenkins user doesn't have
>> permissions to do this (it doesn't even exist on the docker image).
>>
>> Here's the output...  you can see that the docker run actually includes
>> the -u 501 and the -u root.
>>
>>
>> [Pipeline] withDockerContainer
>> $ docker run -t -d -u 501:501 -u root -w /home/jenkins/workspace/ity-se
>> rvice_tlester_jenkins-ZAK24AVEOSII6FI5ZPP6GCRQQ7ISJCROTD5BZVI3M4MT7EMS4ERA
>> -v /home/jenkins/workspace/ity-service_tlester_jenkins-ZAK24AVE
>> OSII6FI5ZPP6GCRQQ7ISJCROTD5BZVI3M4MT7EMS4ERA:/home/jenkins/workspace/ity-
>> service_tlester_jenkins-ZAK24AVEOSII6FI5ZPP6GCR
>> QQ7ISJCROTD5BZVI3M4MT7EMS4ERA:rw -v /home/jenkins/workspace/ity-se
>> rvice_tlester_jenkins-ZAK24AVEOSII6FI5ZPP6GCRQQ7ISJCROTD5BZV
>> I3M4MT7EMS4ERA@tmp:/home/jenkins/workspace/ity-service_tlester_jenkins-
>> ZAK24AVEOSII6FI5ZPP6GCRQQ7ISJCROTD5BZVI3M4MT7EMS4ERA@tmp:rw -e ******** -e
>> ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e
>> ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e
>> ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e
>> ******** -e ******** -e ******** -e ******** --entrypoint cat maven:3-
>> alpine
>> [Pipeline] {
>> [Pipeline] stage
>> [Pipeline] { (Example Build)
>> [Pipeline] sh
>> [ity-service_tlester_jenkins-ZAK24AVEOSII6FI5ZPP6GCRQQ7ISJCR
>> OTD5BZVI3M4MT7EMS4ERA] Running shell script
>> + ps -ef
>> PID USER TIME COMMAND
>>  1 root 0:00 cat
>>  7 root 0:00 sh -c echo $$ > '/home/jenkins/workspace/ity-s
>> ervice_tlester_jenkins-ZAK24AVEOSII6FI5ZPP6GCRQQ7ISJCROTD5BZ
>> VI3M4MT7EMS4ERA@tmp/durable-4de63803/pid'; jsc=durable-8732979585d96e4fbb
>> b59583fb030a62; JENKINS_SERVER_COOKIE=$jsc '/home/jenkins/workspace/ity-s
>> ervice_tlester_jenkins-ZAK24AVEOSII6FI5ZPP6GCRQQ7ISJCROTD5BZ
>> VI3M4MT7EMS4ERA@tmp/durable-4de63803/script.sh' >
>> '/home/jenkins/workspace/ity-service_tlester_jenkins-ZAK24AV
>> EOSII6FI5ZPP6GCRQQ7ISJCROTD5BZVI3M4MT7EMS4ERA@tmp/durable-
>> 4de63803/jenkins-log.txt' 2>&1; echo $? > '/home/jenkins/workspace/ity-s
>> ervice_tlester_jenkins-ZAK24AVEOSII6FI5ZPP6GCRQQ7ISJCROTD5BZ
>> VI3M4MT7EMS4ERA@tmp/durable-4de63803/jenkins-result.txt'
>>  12 root 0:00 {script.sh} /bin/sh -xe /home/jenkins/workspace/ity-se
>> rvice_tlester_jenkins-ZAK24AVEOSII6FI5ZPP6GCRQQ7ISJCROTD5BZV
>> I3M4MT7EMS4ERA@tmp/durable-4de63803/script.sh
>>  13 root 0:00 ps -ef
>> [Pipeline] }
>> [Pipeline] // stage
>>
>> [Pipeline] }
>> $ docker stop --time=1 2955c0a99e3468245e1d72e9986af7
>> 20b4be5f0eba05911d6de5f1e8919e8152
>> $ docker rm -f 2955c0a99e3468245e1d72e9986af7
>> 20b4be5f0eba05911d6de5f1e8919e8152
>> [Pipeline] // withDockerContainer
>> [Pipeline] }
>> [Pipeline] // node
>> [Pipeline] End of Pipeline
>>
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Jenkins Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to jenkinsci-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/jenkinsci-users/ba344ed6-81a9-42b8-a582-688a90e3df84%40googlegroups.
> com
> <https://groups.google.com/d/msgid/jenkinsci-users/ba344ed6-81a9-42b8-a582-688a90e3df84%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CANMVJz%3Doe9wUKep_Nx4HF%2B44F-tmfKbuzL20SWvdiqFdQSE8jw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to