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

Jenkins Pipeline build fails when trying to jenkins docker plugin

      I have Jenkins master running in a docker container and using jenkins docker plugin, I am spawning a jenkins slave (jnlp) on a remote machine. 

      Now, using my declarative pipelines I build my project where i spawn another docker container for builds (inside the slave container spawned by docker plugin)

      This works if the build step has "echo". But when i try to run "sh" in build steps where sh just has "python --version" it gives the following error

      sh: /workspace/conda-test_master-UI6XA7VOZBDYE3YLPHIIQRESPXQMQIXWNY5GVA2M2NXDSM24G6VA@tmp/durable-250f016b/jenkins-log.txt: No such file or directory
      sh: /workspace/conda-test_master-UI6XA7VOZBDYE3YLPHIIQRESPXQMQIXWNY5GVA2M2NXDSM24G6VA@tmp/durable-250f016b/jenkins-result.txt.tmp: No such file or directory
      mv: cannot stat '/workspace/conda-test_master-UI6XA7VOZBDYE3YLPHIIQRESPXQMQIXWNY5GVA2M2NXDSM24G6VA@tmp/durable-250f016b/jenkins-result.txt.tmp': No such file or directory

       

      I am running jenkinsci/[blueocean|https://hub.docker.com/r/jenkinsci/blueocean/]:1.8.0 for Jenkins master

          [JENKINS-53259] Jenkins Pipeline build fails when trying to jenkins docker plugin

          I just reproduced this exact issue on latest version of jenkins+docker plugin. I am adding component docker-workflow-plugin to the issue

          Frederic Rousseau added a comment - I just reproduced this exact issue on latest version of jenkins+docker plugin. I am adding component docker-workflow-plugin to the issue

          Chris Maes added a comment -

          I also have this problem with:

          • jenkins 2.150.3
          • docker plugin 1.1.6
          • docker pipeline 1.17

          Chris Maes added a comment - I also have this problem with: jenkins 2.150.3 docker plugin 1.1.6 docker pipeline 1.17

          Chris Maes added a comment - - edited

          I am trying to run the docker process on another server (not on Jenkins master); something like this:

          node('master') { 
                  withDockerServer([uri: 'tcp://docker-server:4243']) { 
                          withDockerContainer([image: 'alpine']) { 
                                  sh "pwd" 
                          } 
                  } 
          }

          this fails with the exact same error. Inspired by https://github.com/jenkinsci/docker/issues/626#issuecomment-358331311 I have to use this workaround:

          • add docker-server as a jenkins slave
          • mount the /home directory of my jenkins user inside the docker. My Jenkinsfile now looks like this:
          node('docker-server') { 
                  withDockerContainer([image: 'alpine', args: '-v /home/jenkins/:/home/jenkins']) { 
                          sh "pwd; ls /usr/local/bin" 
                  } 
          }
          • for scripted pipeline:
          pipeline { 
                  agent any
                  stages { 
                          stage('test run on docker') { 
                                  agent { 
                                          docker {
                                                  label 'docker-host'
                                                  image 'alpine' 
                                                  args '-v /home/jenkins:/home/jenkins' 
                                          } 
                                  } 
                                  steps { 
                                          sh "pwd" 
                                  } 
                          } 
                  } 
          }

          it is just sad that I need to add the docker-server as a node...

          Chris Maes added a comment - - edited I am trying to run the docker process on another server (not on Jenkins master); something like this: node( 'master' ) {        withDockerServer([uri: 'tcp: //docker-server:4243' ]) {                withDockerContainer([image: 'alpine' ]) {                        sh "pwd"                }        } } this fails with the exact same error. Inspired by https://github.com/jenkinsci/docker/issues/626#issuecomment-358331311  I have to use this workaround: add docker-server as a jenkins slave mount the /home directory of my jenkins user inside the docker. My Jenkinsfile now looks like this: node( 'docker-server' ) {        withDockerContainer([image: 'alpine' , args: '-v /home/jenkins/:/home/jenkins' ]) {                sh "pwd; ls /usr/local/bin"        } } for scripted pipeline: pipeline {        agent any        stages {                stage( 'test run on docker' ) {                        agent {                                docker { label 'docker-host'                                        image 'alpine'                                        args '-v /home/jenkins:/home/jenkins'                                }                        }                        steps {                                sh "pwd"                        }                }        } } it is just sad that I need to add the docker-server as a node...

          pjdarton added a comment -

          FYI pipeline code like withDockerServer means you're using the docker-workflow-plugin not the docker-plugin.  I've updated the "components" field accordingly.

          pjdarton added a comment - FYI pipeline code like withDockerServer means you're using the docker-workflow-plugin not the docker-plugin.  I've updated the "components" field accordingly.

            Unassigned Unassigned
            siddhant_aqr Siddhant Gogri
            Votes:
            6 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated: