Azure DevOps Cancel deployment of stage when deploying another stage

好久不见. 提交于 2021-02-10 18:32:18

问题


We currently have our Azure DevOps release setup in the following way:

What I'm trying to accomplish is to cancel the 2:00 PM deployment if the 9:00 AM deployment triggers, as well as cancel the 9:00 AM deployment if the 2:00 PM deployment triggers since we don't really want to deploy the same code twice, or even deploy the previous day's code the following day.

Does anyone know if a way to do this in Azure DevOps?

I've done a lot of searching for extensions, etc. to see if I can find anything, but so far have not been successful. Any help would be greatly appreciated.


回答1:


Additionally, you may try to use Release Gates with Rest Api or Azure Functions. You can find example here: Azure DevOps release gates with Azure Functions, PowerShell and VS Code




回答2:


Assuming you trigger the release at 9:00 AM. Then you can take the following steps to implement it:

1.Add a variable named flag and set it as true in the Variable Tab

2.Add a PowerShell Task to your Test Stage, Starting 9:00 AM Stage and Starting 2:00 PM Stage

(1) Add a powershell task at the end of your Test Stage to set the flag to true.

(2) Add a powershell task on the top of Starting 9:00 AM Stage to check if the variable flag is true, If flag is false then fail this task, Below script is for example.

$flag = “$(flag)”

if(-Not $flag)

{

exit 1

}

Add a powershell task at the end of Starting 9:00 AM Stage to set the flag to false, if this stage is deployed successfully.

Repeat above steps for 2:00 PM Stage.



来源:https://stackoverflow.com/questions/59326612/azure-devops-cancel-deployment-of-stage-when-deploying-another-stage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!