Permission denied from Bitbucket pipeline
The issue is that the file was not given the correct execution permissions before it was checked into BitBucket.
If you are developing locally in a unix environment, you would normally set execute permissions (ie. chmod 755) on the script file so you can test it locally before committing. With this approach you would not experience the permission denied error in pipeline build when you check it in.
However, sometimes we are authoring our scripts on Windows without a unix emulator, so we can only test our scripts in a pipeline environment. Even though Windows does not support execute permissions in its file system, we can still use git to show and set these execute permissions.
cd <dir-with-shell-scripts>
git ls-files --stage # show file permissions (last 3 digits of first number)
git update-index --chmod=+x <files> # set execute permissions
Commit the updated files as per your normal process.
This looks like Linux permissions problem to me rather than programming. Check if the script has executable permission (the x bit in ls -l
). You can consult chmod (man chmod
) or the Internet for details how Linux permissions work, as I believe that is offtopic for this site.
It turns out that right before i execute the script i had to use - chmod +x deploy-hockey-dev.sh
so the .yml file that is used in bitbucket should have this line before the execution of the script. I made a tutorial of how to make the entire process hope it help some one.