I am trying to find a simple solution for:
- Step: Sanity check
- if: sanity check failed
- Step: Run Update
block step should only be shown if the sanity check failed (so some human can check), if the sanity check passes, we can go straight to
a) Sanity check fails:
S -> B -> U
b) Sanity check passes:
S -> U
I don’t think I can “communicate” between steps using
passed, failed as I never want to fail the build.
An alternative could be to duplicate the "Run Update step and use
depends_on, but that violates the DRY principle:
S -> B -> U1
S -> B2
Thanks for checking with us!
We can check the outcome of the “Sanity check” step and then dynamically upload a block step based on the result of the ‘Sanity check’. We also need to soft_fail the ‘Sanity check” step, so it continues to run the remaining steps in the pipeline even when it fails.
A sample pipeline would be like this:
- command: exit -1
- exit_status: "*"
- wait: ~
- command : |
if [ $$(buildkite-agent step get "outcome" --step "sanity-check") == "soft_failed" ]; then
cat <<- YAML | buildkite-agent pipeline upload
- block: "sanity is failed. check and unblock me."
- wait: ~
- command: echo "running regression"
Some useful info on the insertion order when using dynamic upload: Steps are inserted immediately following the job performing the pipeline upload. Note that if you perform multiple uploads from a single step, they can appear to be in reverse order, because the later uploads are inserted earlier in the pipeline.
Hope this helps solve your use case!
Let us know for any questions!
Thanks for the quick reply. It is not the prettiest solution though :) Would be nice if it would be possible to just use an if on a later step rather than injecting yaml. But I’ve done it that way and it works perfectly.