Hello All,
I am running Jenkins (2.121.1) inside a Docker container and I use ssh node as build nodes. I want to use withDockerContainer in my pipeline as shown in /1/ and getting an error as shown in /2/. Could you please help me to resolve this issue?
/1/
pipeline {
agent { label "build" }
stages {
stage("test") {
steps {
withDockerContainer (image: 'busybox') {
sh 'pwd'
}
}
}
}
}
/2/
Started by user Jeeva S. Chelladhurai
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] node
Running on build-server in /home/ubuntu/workspace/sandbox/withdocker
[Pipeline] {
[Pipeline] stage
[Pipeline] { (test)
[Pipeline] withDockerContainer
build-server does not seem to be running inside a container
$ docker run -t -d -u 1000:1000 -w /home/ubuntu/workspace/sandbox/withdocker -v /home/ubuntu/workspace/sandbox/withdocker:/home/ubuntu/workspace/sandbox/withdocker:rw,z -v /home/ubuntu/workspace/sandbox/withdocker@tmp:/home/ubuntu/workspace/sandbox/withdocker@tmp:rw,z -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** busybox cat
$ docker top 661025c3ef5f46681fd3f9c73c8e0522c7dbcbbf35d8531aab0aa4739d5ee840 -eo pid,comm
[Pipeline] {
[Pipeline] sh
[withdocker] Running shell script
invalid argument "=" for "-e, --env" flag: invalid environment variable: =
See 'docker exec --help'.
process apparently never started in /home/ubuntu/workspace/sandbox/withdocker@tmp/durable-a265513a
[Pipeline] }
$ docker stop --time=1 661025c3ef5f46681fd3f9c73c8e0522c7dbcbbf35d8531aab0aa4739d5ee840
$ docker rm -f 661025c3ef5f46681fd3f9c73c8e0522c7dbcbbf35d8531aab0aa4739d5ee840
[Pipeline] // withDockerContainer
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code -2
Finished: FAILURE