Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-52211

In Docker pipeline plugin - withDockerContainer step is not working as expeted

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Blocker Blocker
    • docker-flow-plugin
    • None

      Hi Developer,

      I am facing some problem while using withDockerContainer step in my jenkins descriptive pipeline script(jenkinsfile), the problems are mentioned below,

      1. If i use -w in args and mention custom workspace its not choosing mentioned custom workspace instead it is choosing the default one.

      2. If i use -e in args its throwing error invalid argument "=" for "-e, --env" flag: invalid environment variable: = See 'docker exec --help'.

      3. even though we do not pass -e args its throwing the above mentioned error

      steps to reproduce the above issues:

      create a job with pipeline and choose pipeline script and copy paste below mentioned code in to script editor

       pipeline {

      agent

      { label "build" }

      stages {
      stage("test") {

      steps {
      withDockerContainer (image: 'busybox')

      { sh 'pwd' }

      }

      }

      }

      }

      Console output:

      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: FAILUR

            vfarcic Viktor Farcic
            dhanu123 Dhanu MC
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: