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.
CodePudding user response:
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
).
Also, note the line separator must be LR
: Unix and MacOS compatible (\n
), otherwise /usr/bin/env: ‘bash\r’: No such file or directory
shows as an error.