You will need about one minute to read this article.
In some workflows, you may want to execute a command only when a previous command has failed. As one example, you may want to run an alerts script if your tests fail.
By default, CodeShip exits a build once their is a failure of any kind, which means when any command reports back a status code other than
0. However, by wrapping your commands in an “on fail” script, you can create a fallback conditionality and then exit your build appropriately afterwards.
To run another command if an earlier one fails you can use the following bash syntax
YOUR_COMMAND || (OTHER_COMMAND && exit 1)
This will still fail the build, but will let you execute another command first. If you are looking for a more flexible solution, take a look at ensure_called.sh.
Contact our support team or post on Stack Overflow using the tag
#codeship. Did you check the status page and changelog?
There are also several code examples and sample projects available for you to get started with.