0

I have installed Jenkins and Docker inside a VM. I am using Jenkins pipeline project and my jenkins declarative pipeline looks like this.

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

It is a very basic pipeline following this link https://jenkins.io/doc/book/pipeline/docker/

When I try to build my jenkins job, it prints Hello Nodejs, but gets stuck at the next instruction i.e. execution of shell command. After 5 minutes, the job fails with this error

process apparently never started in /var/lib/jenkins/workspace/MyProject@tmp/durable-c118923c
(running Jenkins temporarily with -Dorg.jenkinsci.plugins.durabletask.BourneShellScript.LAUNCH_DIAGNOSTICS=true might make the problem clearer)
ERROR: script returned exit code -2

I am not understanding why it is not executing the sh command.

This is the screenshot of console output

If I make it as agent any, it executes the sh command.

Kara
  • 6,115
  • 16
  • 50
  • 57
Tarun Chawla
  • 321
  • 1
  • 2
  • 11
  • Please see my reply in this thread: https://stackoverflow.com/questions/58346984/jenkins-pipeline-error-process-apparently-never-started-in/58625316#58625316 – cipher0 Oct 30 '19 at 14:59
  • I have the same issue. Were you able to solve it? – Daghan --- Feb 02 '21 at 23:49

1 Answers1

1

I am not sure that it will help but I remember that node image is launched under root account by default. Jenkins uses its own ID when launching a container. So, probably, it's a permissions issue. Try to add -u 0 argument:

agent {
    docker {
        image 'node:7-alpine'
        args '-u 0'
    }
}
Marat
  • 161
  • 6