4

The "mvn clean" stage is getting stuck for sometime and lead to the following error:

[Pipeline] sh
process apparently never started in /home/jenkins/jenkins/workspace/<MyProject>@tmp/durable-8e4de4ec
(running Jenkins temporarily with -D 
org.jenkinsci.plugins.durabletask.BourneShellScript.LAUNCH_DIAGNOSTICS=true might make the problem 
clearer)
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code -2
Finished: FAILURE

Here is my jenkinsfile script:

pipeline{
agent{
    label 'DOCKER'
}
tools { 
    maven 'M3' 
    jdk 'JAVA_HOME' 
}
stages{
    stage('build'){
        steps{
            echo 'Running Build Phase'
            sh 'mvn clean'
        }
    }
}
}

Not sure if I need to update any configurations. I have updated /etc/init.d/jenkins with updated open-jdk version.

enter image description here

Siddharth Shankar
  • 489
  • 1
  • 10
  • 21
  • Hey, I am facing a similar issue. Did you find anything on this? – Rana Ranvijay Singh Jan 21 '20 at 09:08
  • Hi @RanaRanvijaySingh, I am not sure what exactly made it work. I followed few posts e.g. https://stackoverflow.com/questions/58346984/jenkins-pipeline-error-process-apparently-never-started-in and tweaked lot of with jenkins and docker config. Though, I did not update any dependencies in the code. Its the issue with config. – Siddharth Shankar Jan 21 '20 at 22:01
  • Thanks for the reply, I got my issue resolved. It was because of environment variables. This might help someone else. https://stackoverflow.com/questions/43987005/jenkins-does-not-recognize-command-sh/59852718#59852718 – Rana Ranvijay Singh Jan 22 '20 at 05:17

3 Answers3

2

I had the same issue and found that if you go Manage Jenkins -> Configure System there will be an empty environment variable in the Global Properties section. Just delete that variable and it fixed the issue.

Binod
  • 39
  • 3
2

Add the following argument to your jenkins java runtime to get more diagnostic info on why the "sh" steps fails:

-Dorg.jenkinsci.plugins.durabletask.BourneShellScript.LAUNCH_DIAGNOSTICS=true

If using with the kubernetes plugin, it may be the issue described here (in the section Pipeline sh step hangs when multiple containers are used).

Sridhar Ratnakumar
  • 81,433
  • 63
  • 146
  • 187
MichaelCkr
  • 540
  • 1
  • 7
  • 14
-1

In my case, my project had a bad name (thus a bad directory name). My project was called "Site's updates" and the ' obviously broke the directory naming. Jenkins was not able to access the directory.

Hope this helps anyone.

pineapple-na
  • 29
  • 1
  • 1
  • 6