1

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

Release Setup

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.

James Z
  • 12,209
  • 10
  • 24
  • 44
MrCyber
  • 11
  • 3

2 Answers2

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

Shamrai Aleksander
  • 13,096
  • 3
  • 24
  • 31
0

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

enter image description here

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.

mj1313
  • 7,930
  • 2
  • 12
  • 32
  • Example: https://stackoverflow.com/questions/53042605/how-to-modify-azure-devops-release-definition-variable-from-a-release-task – Shamrai Aleksander Dec 16 '19 at 11:36
  • @MrCyber Is the plan given by me or Shamrai Aleksander helpful to you? If you have any questions, feel free to tell us. – mj1313 Dec 19 '19 at 01:26