jenkinsjenkins-pipeline

permission denied when executing the jenkins sh pipeline step


I have some trouble with this situation: everytime I create a new pipeline job ( entitled "pipeline"), the sh step won't work even with simple command like ls or pwd and it returns this log:

sh: 1: /var/jenkins_home/workspace/pipeline@tmp/durable-34c21b81/script.sh: Permission denied

Any suggestions?


Solution

  • I guess you use

    stage(name){
       sh ./runSomething
    }
    

    Jenkins always uses to user jenkins for running scripts. There are some possibilities:

    1. Jenkins is running with a different user, maybe you start it with some other user.
    2. Something went running when installing jenkins, check that you have a jenkins user