0

I have a new Jenkins installation. I want to run my entire pipeline in a downloaded Docker container.

When I use the below Jenkinsfile, everything works (note: I have docker installed on the Jenkins host)

pipeline {
    agent any

    stages {
        stage('Test') {
            steps {
                sh 'docker -v'
            }
        }
    }
}

Everything works for the above example, see build run nr 13 in the screenshot below.

Then, I change the Jenkinsfile to the following:

pipeline {
    agent {
        docker { image 'node:7-alpine' }
    }
    stages {
        stage('Test') {
            steps {
                sh 'node --version'
            }
        }
    }
}

The idea is that the node:7-alpine image gets downloaded and that the next steps are executed inside that container. However the Docker images does not seem to get downloaded at all and the pipeline does not go to the 'Test' stage. See screenshot below, build nr 14

enter image description here

Edit 1:

Clarification: in build nr 14, the "Declarative: checkout SCM" step completes successfully (see below screenshot for the output of that first step), but it does not go to the next step.

enter image description here

Edit 2:

Console output shows the following error:

enter image description here

On the Jenkins host, I have added my user to the docker group and can execute commands like 'docker ps' and 'docker images'

Any ideas?

wiwa1978
  • 2,317
  • 3
  • 31
  • 67
  • Can you please post an error from the build log? – Vitalii Vitrenko Dec 24 '19 at 13:22
  • @VitaliiVitrenko I clarified the original post a bit, but there is no error, the pipeline simply does not continue to the next step. – wiwa1978 Dec 24 '19 at 13:28
  • Does the [Console Output](https://www.softpost.org/jenkins/viewing-the-build-logs-and-results-in-jenkins/) window also not contain any errors? – Vitalii Vitrenko Dec 24 '19 at 13:43
  • @VitaliiVitrenko Thanks, good point. Yes indeed, I get 'Got permission denied' error. See edit 2 in the original post – wiwa1978 Dec 24 '19 at 13:52
  • Please refer to this answer https://stackoverflow.com/a/44444163/4624905. Also note that as described Jenkins have to be restarted from command line. – Vitalii Vitrenko Dec 24 '19 at 14:05
  • I had come across that post but does not work. I added the user to the docker group using 'sudo usermod -aG docker ' and restarted Jenkins using 'sudo service jenkins restart'. Additional info: I'm not running Jenkins itself in a container, i'm running Jenkins on VM. – wiwa1978 Dec 24 '19 at 15:46
  • @VitaliiVitrenko You were right. I executed the command 'sudo usermod -aG docker ' for the wrong user. It should have been 'sudo usermod -aG docker jenkins' and then 'sudo service jenkins restart'. This fixed the issue. – wiwa1978 Dec 24 '19 at 15:54
  • That's great!. Voted as duplicate of stackoverflow.com/a/44444163/4624905 as this was basically the same issue. – Vitalii Vitrenko Dec 24 '19 at 16:05

0 Answers0