This article is about CodeShip Basic.

Running A Fallback Command

You will need about one minute to read this article.

Running A Command If A Step Fails

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.

Using The “On Fail” Script

To run another command if an earlier one fails you can use the following bash syntax


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

Need more help?

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.

Article not helpful?

Does this article need improvement? If so, please send feedback or submit a pull request!