3
votes

I have a multi-stage pipeline YAML deploying to different environments (PreDev-Dev-QA-Stage-Prod) and i'm trying to implement rollback strategy to rollback to previous version or previous build artifact and was looking at this page https://docs.microsoft.com/en-us/azure/devops/pipelines/process/deployment-jobs?view=azure-devops but couldn't figure out and also didn't find any examples. Any help is appreciated

2
Check this rule, if the answer could give you some help. you can consider accepting it as answer . It just a reminder :)Kevin Lu-MSFT

2 Answers

4
votes

According to the doc:

We currently only support the runOnce, rolling, and the canary strategies.

The rollback strategy doesn't seem to support in Yaml definition.

But you can manually run the previous stage again. Then the pipeline could rollback to the previous version.

Step1: Navigate to the build summary page of the previous build.

Step2: Select the stage and use "Rerun Stage" optiom.

Rerun Stage

Hope this helps.

0
votes

What about adding an additional stage, which could be called Rollback.

This stage could use Kubectl to do a rollback:

kubectl rollout undo deployment/$DEPLOYMENT

To avoid having the stage run every time just add a manual approval or you could add a gate that checks if the deployment was successful, with a health check call, or checking for monitoring alerts, or by running integration tests.

https://docs.microsoft.com/en-us/azure/devops/pipelines/release/approvals/gates?view=azure-devops