Reputation: 2478
I have a circle.yml
file like so:
dependencies:
override:
- meteor || curl https://install.meteor.com | /bin/sh
deployment:
production:
branch: "master"
commands:
- ./deploy.sh
When I push to Github, I get the error:
/home/ubuntu/myproject/deploy.sh returned exit code 126
bash: line 1: /home/ubuntu/myproject/deploy.sh: Permission denied Action failed: /home/ubuntu/myproject/deploy.sh
When I run the commands that live inside deploy.sh
outside of the file (under commands
) everything runs fine.
Everything in the circle.yml
file seems to be in line with the examples in the CircleCI docs.. What am I doing wrong?
Upvotes: 31
Views: 22306
Reputation: 521
I was having the same issue. I added sh
to the front of my commands section to get it to work.
deployment:
production:
branch: "master"
commands:
- sh ./deploy.sh
Hopefully that fix saves everyone sometime going forward.
Upvotes: 35
Reputation: 1924
Assuming you have already checked it in, use this command to flag it as executable to git:
git update-index --chmod=+x script.sh
reference: https://www.pixelninja.me/make-script-committed-to-git-executable/
Upvotes: 17
Reputation: 5036
As @palfrey says the script is probably not marked as executable, and sometimes it seems to be marked wrong on deployment even when you have previously run chmod +x
on your script at your local machine. (Why? I don't know. If someone does please enlighten me!)
Here is a general command to use to ensure your scripts are always marked as executable. This assumes they are all located in a /home/ubuntu/${CIRCLE_PROJECT_REPONAME}/scripts
directory and all have a .sh
extension. If your directory(s) is(are) different, edit to use your directory instead.
Since all my scripts source a shared script (shared.sh
) at the top of each script that are called by circle.yml
I add the following code to shared.sh
which ensures all scripts are marked as executable:
SCRIPTS="/home/ubuntu/${CIRCLE_PROJECT_REPONAME}/scripts"
find "${SCRIPTS}" | grep "\.sh$" | xargs chmod +x
Works like a charm. :-)
Upvotes: 0
Reputation: 1697
Several possible problems:
chmod +x deploy.sh
would fix this)If the first doesn't work, can we please see the contents of deploy.sh?
Upvotes: 51