Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Permission denied from Bitbucket pipeline

I am trying to use the bitbucket pipeline to upload my build apk to hockey app but when i try to run my script i get

bash: ./deploy-hockey-dev.sh: Permission denied

this is the deploy-hockey-dev.sh :

#!/bin/sh

# upload apk to hockey app
curl \
-F "status=2" \
-F "notify=0" \
-F "ipa=@app/build/outputs/apk/debug/app-debug.apk" \
-H "X-HockeyAppToken: myToken" \
https://rink.hockeyapp.net/api/2/apps/upload

Does any one know what the problem here is ?

like image 586
Ivan Avatar asked Oct 24 '18 16:10

Ivan


People also ask

How do I fix permission is denied in Unix?

To fix the permission denied error in Linux, one needs to change the file permission of the script. Use the “chmod” (change mode) command for this purpose.

How do I fix permission denied Publickey password?

Solution 1: Enable Password Authentication If you want to use a password to access the SSH server, a solution for fixing the Permission denied error is to enable password login in the sshd_config file. In the file, find the PasswordAuthentication line and make sure it ends with yes .


2 Answers

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.

like image 88
AlexW Avatar answered Sep 28 '22 01:09

AlexW


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.

like image 34
Ivan Avatar answered Sep 28 '22 01:09

Ivan