Permission denied from Bitbucket pipeline
Asked Answered
M

4

20

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 ?

Michail answered 24/10, 2018 at 16:17 Comment(0)
M
14

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.

Michail answered 26/10, 2018 at 16:17 Comment(0)
K
25

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.

Knowles answered 16/12, 2020 at 1:52 Comment(1)
this should be the answerDarcidarcia
M
14

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.

Michail answered 26/10, 2018 at 16:17 Comment(0)
F
2

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.

Fitzpatrick answered 24/10, 2018 at 16:22 Comment(0)
H
0

This worked for me. In your code terminal, you need to update the permissions for the files to be executable (x in them)

chmod +x path/to/file 

Then commit and push. The pipeline should pass for this issue

Human answered 1/2, 2022 at 13:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.