permission denied when executing the jenkins sh pipeline step
Solution 1:
I was getting a similar permissions denied error after following the Jenkins pipeline tutorial for a node project.
./jenkins/test.sh: Permission denied
The original pipeline Test stage looked like the following and returned that error.
stage('Test') {
steps {
sh './jenkins/test.sh'
}
}
I found the following post: https://stackoverflow.com/a/61956744/9109504 and modified the Test stage to the following
stage('Test') {
steps {
sh "chmod +x -R ${env.WORKSPACE}"
sh './jenkins/test.sh'
}
}
That change fixed the permissions denied error.
Solution 2:
I guess you use
stage(name){
sh ./runSomething
}
Jenkins always uses to user jenkins for running scripts. There are some possibilities:
- Jenkins is running with a different user, maybe you start it with some other user.
- Something went running when installing jenkins, check that you have a jenkins user