简体   繁体   中英

Jenkins permission denied - how to change rights from IntelliJ Idea and Windows?

I have a Jenkinsfile with the following stage executing a bash ( sh ) script:

stage('Prepare') {
    sh 'cd ./bin && ./prepare.sh'
}

The Jenkins fails the stage producing an error:

 14:27:16 + cd ./bin 14:27:16 + ./prepare.sh 14:27:16 /data/jenkins/workspace/repo_J_tmp/durable-8864902e/script.sh: line 1: ./prepare.sh: Permission denied

I use IntelliJ Idea and Windows. How to change and push the rights?

The command chmod=+x ./bin/prepare.sh in Git Bash is not registered as a change, so there is nothing to commit.

It is needed to use git --update-index with Git Bash and then perform the commit through the Windows command line.

The sequence of commands follows (assuming Git Bash is installed):

PS C:\Development\repo> bash
user@DESKTOP-ABCDEFG:/mnt/c/Development/repo$ git update-index --chmod=+x ./docs/prepare.sh
user@DESKTOP-ABCDEFG:/mnt/c/Development/repo$ exit
PS C:\Development\repo> git commit -m"Executable Script"

The commit is ready to be pushed ( ctrl + shift + k or git push ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM