Stopping the pipeline on first failure


#1

I have three shell scripts that execute in order. Each has ‘set -e’ in place to ensure that the return code is non-zero. I expected the pipeline to stop at first failure. It does not. I see https://github.com/envato/stop-the-line-buildkite-plugin, but I cannot figure out how to configure it for a non-YAML pipeline.

Of course, I have a workaround - I can delete two of the .sh scripts and put their contents in a single monolithic one. Defeats the elegance of a build pipeline, of course :-(

Advice?

  • Paul

#2

Hey Paul, by the sounds of it - I think you should be able to split your 3 shell scripts into 3 seperate build steps, with a “wait” step in between.

In YAML, it’d look something like this:

steps:
  - command: “script1.sh”
  - wait
  - command: “script2.sh”
  - wait
  - command: “script3.sh”

And using the Step UI it’d look like this:

With this setup, the pipeline will fail and stop running if script1 or script2 fails.

Does something like that work?


#3

Trying that now Keith. I was looking in the wrong place!! (user error)


#4

No worries, let me know how you go!