Is there a way to create a stage that runs last, no matter the outcome of the pipeline?

Viewed 41

I have a multistage yaml pipeline that looks something like this. I need a stage that runs at the end of the pipeline run. No matter the outcome of the pipeline. even if it fails the stage should still run. Is there a way to define conditions or something that would be able to do this.

pipeline

1 Answers

To make sure the stage always runs, use the always() condition; and to make it run after the other stages, you can either put it last in the yaml file or define explicit dependencies:

- stage: runLast
  condition: always()
  dependsOn:
    - stageX
    - stageY
    - stageZ

Note: you may not want the stage to run if you've cancelled the pipeline; in that case, the condition to use is succeededOrFailed()

Related