Run a command after another command fails

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.