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?

You can post on Stack Overflow using the tag #codeship or contact our Helpdesk.
We also have a couple of code examples and sample projects available for you to get started with.

Article not helpful?

Do you think we need to improve this article? If so, please submit our feedback form to help us improve this article!