Ignoring a failing step?

#1

Is there a way to define a step that is allowed to fail? It would come in handy to run certain sanity checks, like linting or static code analysis.
It’s important to create visibility on these steps, but they are not necessarily blocking.

I know there is the continue_on_failure on wait steps, but it will not work for this use case for example:

- command: "lint.sh"
- wait: ~
  continue_on_failure: true
- command: "echo Building code"
- wait
- command: "echo Deploying code"

If the linting failed the deployment will never happen, even if the failure wasn’t exactly blocking.

0 Likes

#2

Hey there @JoniV — thanks very much for posting and welcome to the forum :slight_smile:

Good news on that front, we totally agree and I’ve actually nearly finished adding support for this. There will be a changelog up about it pretty soon, but essentially you will be able to allow steps to “soft-fail”. Soft failed steps are still failures, they just don’t cause the whole pipeline to fail too, and are opted into via listing allowed exit statuses.

Cheers,
Justin

1 Like

#3

Fantastic. I’ll keep an eye on that.

0 Likes

#4

I know this isn’t exactly what you want, but another way to get around this for now would be to add || true

- command: "lint.sh || true" # ignore failures
- wait
- command: "echo Building code"
- wait
- command: "echo Deploying code"

Of course that will then make it appear as if the step isn’t failing, but maybe it would be acceptable. If you wanted to surface lint errors more, you could also use buildkite-agent annotate to make note of the hidden failure.

1 Like

#5

Thank you, that’s another work-around.

I had the script return exit 0, because I still wanted to make sure some of the steps returned failures but it’s getting a bit noisy.

0 Likes

#6

Just a quick update here so you don’t think I’ve forgotten :upside_down_face: — this is still coming, just got delayed a little last week. If the stars align I’ll hopefully get this out the door this week.

3 Likes