Ignoring A Failure In A Step

In some instances, you may need a job to continue running even if a step returns a non zero exit code. This could be due to a subsequent dependant job in a workflow, or that the success of a step is not a contributing factor to the success of your pipeline.

Note: Use the following with caution. Ensure you absolutely need this functionality for the particular step, otherwise failures in your jobs may go unnoticed which may have knock-on effects.

The easiest way to implement this is to set up the step as follows:

- run: my_cool_command || true

This ensures that the step always returns a zero exit code, regardless of if the command fails or not.

If you have a mutli-line command, or a script file, then you may consider overriding the default shell options to ensure an exit code zero is passed:

- run:
shell: /bin/bash
command: |
echo Running my cool command
mkdir ~/some_dir

For more details on how the default shell options work, and why they have been chosen as the default, please see our documentation.

Was this article helpful?
2 out of 15 found this helpful



Article is closed for comments.