How do I allow cleanup steps to run if a dependent step is cancelled?

I’ve got a pipeline with multiple canary evaluations being performed. Each of these evaluation stages are listed as dependencies for my cleanup stage near the end of my pipeline. If one of these stages needs to be aborted due to production incidents etc, how do I allow the cleanup stage to still execute?

Edit. Is there an alternative approach that should/could be taken to achieve this if this is not possible?


Hi @saj

First of welcome to Buildkite community and thank you for reaching out to us

One option is to define pre-exit command hook where you can check if build.state is failed or cancelled (based on which ever state you need clean up to happen) then trigger your clean up task.

1 Like

This worked for me

- label: Some earlier task
  key: earlierthing
- wait: ~
  continue_on_failure: true
  depends_on: earlierthing
  allow_dependency_failure: true
- label: Cleanup on failure or cancel
  command: whatever