Deploy failing with git pull yet still passing


My deploy script is an extremely simple Git pull. I have a bash script that does git pull that’s part of my source code. The issue is that if the git pull fails for any reason, it’s still showing a successful deploy.

In circle CI, my deploy commands are:
branch: master
- ./
branch: staging
- ./

deploy-to-production is a simple script that lets CircleCI ssh and run the pull
#!/usr/bin/env bash
ssh -i ~/.ssh/ -t “cd /home/xxxxx/yyyyy && ./”

The issue is that git pull can fail, but the deploy still shows that it passes. Below is the output (the git conflict caused it to fail) but CircleCI shows green.

Warning: Identity file /home/ubuntu/.ssh/ not accessible: No such file or directory.
Warning: Permanently added ‘,’ (ECDSA) to the list of known hosts.


remote: Counting objects: 3, done.
remote: Compressing objects: 100% (1/1), done.
remote: Total 3 (delta 2), reused 3 (delta 2), pack-reused 0
Unpacking objects: 100% (3/3), done.
f23cff8…1793a48 master -> origin/master
Updating f23cff8…1793a48
error: Your local changes to the following files would be overwritten by merge:
Please, commit your changes or stash them before you can merge.
Running any db migrations.

Yii Migration Tool v1.0 (based on Yii v1.1.8)

No new migration found. Your system is up-to-date.

Connection to closed.


I have a similar issue with a deploy script using fastlane. The archiving step fails and therefore fastlane fails, but CircleCI reports the build as a success. This means builds are failing to be deployed, but I never get notified of the failure. The docs say:

If a command fails during any of the setup sections (machine, checkout, dependencies, database, compile), the entire build will fail early.

Apparently a failure in the deploy section does not cause the build to fail. Is there a way I can propagate the exit code to CircleCI so the build fails on deploy? Do I need to place my deploy code in a different section?


You could try placing the script is test: post. You’d then need to use Bash to make sure it only runs on the branches you want, i.e. master.


Seems like a bit of a hack, but it would work! Thanks for the idea.