Azure DevOps scheduled release with approvals - azure-devops

I have a question concerning a release pipeline with both a schedule, as well as approvals.
Right now, the pipeline flows as follows:
A new build is triggered by a merge on our master branch
From the new build, a new release is automatically created
The schedule of this release is to wait until Saturday morning 3 AM to fire
On 3 AM, it sends approval requests for the people in the pipeline
After approval, the release happens
Steps 3, 4 and 5 are in the wrong order for our process. What it actually should do is:
Ask for approval
After approval, schedule the build for a release on Saturday 3 AM
Initiate the release
I can get there by introducing an empty stage that only handles the approval part, and in a next stage handle the deployment per schedule. But that seems like a workaround for something that should be doable in a better way. So am I missing an option here, or is this the way to do it?

#ChamindaC is correct. Your solution to have an Approval Stage that would precede the Scheduled stage is how the ordering of approvals and triggers can be accomplished.
I believe the order of appearance in the per stage Pre-deployment Conditions menu is also the order of execution.

Related

Run Azure Release Pipeline stage if one of many dependent stages runs

We have a rather large deployment surface, say 10 apps that get deployed. For patch releases we sometimes deploy only one app and I'd like to have a stage run either after all 10 are deployed or if only one is deployed. A simplified graph looks like the following. The "Do Something" step will only run if all three app stages run and I don't want to have to duplicate it for each app so looking for a better way. I guess that I could live with it if it just ran one time on any successful dependent stage (doesn't need to wait for all of them).
So I think there are a couple options for this. Will need to look at YAML Multi stage release pipelines. Specifically, deployment jobs
First depending on complexity of the "Do something" stage, it could be a job template and loaded into each of the app stages. I realize you mentioned you don't want it to run every time so this is just an option.
The second option is if the pipeline is being ran adhoc you will have the ability to select which stages are ran. Thus you could manually select the app stages to run and select the "do something stage" It will look something similar to this. The hard part will be working on the dependencies:
I'd assumed you'd want the "do something" to be dependent on the success of one of the previous stages.
Run Azure Release Pipeline stage if one of many dependent stages runs
I am afraidthere is no such out of way to achieve this at this moment.
That is because there is no "OR" syntax for the depend on. And we could not add the condition for the depend on.
You could submit this request condition "OR" to our UserVoice site (https://developercommunity.visualstudio.com/content/idea/post.html?space=21 ), which is our main forum for product suggestions. Thank you for helping us build a better Azure DevOps.
As workaround:
The main idea of the solution is: You could try to set depend on for the stage Secure with [], then add a Inline powershell task before other tasks. This task will call the REST API Definitions - Get to monitor whether all the stages in the current release pipeline have inprocess and queue states. If so, wait for 30 seconds, and then loop again until all other stages in the current release pipeline have no inprocess and queue states. Then next execute other tasks will be executed.
You could check my previous ticket for detailed info:

Azure DevOps - schedule release deployment is not available

In Azure DevOps you can schedule a release as many times as possible. In my example, I want to create a release 3 times a day Monday - Friday
But, if I need to actually deploy those releases 3 times a day Monday - Friday, I can't. There is only one slot available and user can't add more.
Is this a limitation of Azure DevOps and how I can actually deploy my release (not create them) 3 times a day?
This is not available at present.
Not sure if totally got your point, what you are looking for is something similar to schedule redeploy.
When you submit a pre-deployment approval for a stage, you can defer the deployment until a specified time. You could not select or specify multiple times here.
You could submit a feature request in Develop Community: https://developercommunity.visualstudio.com/spaces/21/index.html
As Patrick pointed out, this currently isn't possible. You can set multiple schedules for a release but individual stages can't be scheduled more than once. As a workaround, you could clone the stage and then set different schedules for it.

Azure Dev Ops - How to require 2 of 3 approvers on pre-deployment approvals?

I have a pre-deployment approval on Azure Dev Ops where I need the approval of two out of three approvers to proceed to the next stage.
However, at the moment the interface makes it look like you can either have all of the three approving or just one of them approving. I wouldn't like to have the three of them approving it because there is always the chance that someone might not be on the office.
Azure Dev Ops - How to require 2 of 3 approvers on pre-deployment approvals?
Indeed, there is really no such option Minimum number of reviewers of branch Policies for pre-deployment approvals at this moment:
If it is important to you, you can open a new ticket here:
Besides, what I can think of is that the workaround is divide the three approvers into three groups (AB, AC, BC), then add the three groups to the Approvers option and select any one user on Approval order option. Of course, when you have many approvers, it can be very troublesome.
Hope this helps.

Is it possible to combine a gate and an approval to limit an Azure deployment?

In Azure, you can limit deployments with gates and approvals. Gates are usually some sort of status or health check. Approvals require a certain user or group to manually approve the deployment.
Is it possible to combine the two?
For example, I'd like for a deployment to require an approval but only if it's before 8 am or after 5 pm.
Another example would be to require an approval if the application is not live (liveness would be determined by a REST call).
No there is no way to create "conditional approvals" this way. You can schedule Gates and/or approvals but can't make one dependent on the other. The only thing you can configure is to ignore the gate and still ask for approvals or ask for approvals and then run the gates.
But what you can, using a custom release gate (Azure Function for example), is to do the required check and then use the Azure DevOps REST API to edit the release instance. An azure function with the right permissions could either enable or disable the approvers on the environment or override an approval.
An example of how to do this can be found here:
https://abelsquidhead.com/index.php/2017/12/25/creating-async-custom-automated-release-gates-in-vsts-with-rest-api/
https://github.com/Microsoft/azure-pipelines-tasks/blob/master/docs/authoring/gates.md
https://github.com/Microsoft/azure-pipelines-extensions/tree/master/ServerTaskHelper/DistributedTask.ServerTask.Remote.Common

Can Go (CI server) send mail for each failed build regardless of pipeline?

I'm using Go as my continuous integration server. I'm trying to get it to send an email if any stage in any pipeline breaks. So far, all I've found is a per-user email configuration, which forces me to add an email event per stage, per pipeline and per event. With 15 stages across 10 pipelines, and 3 events to trigger on, that's a lot of configuration.
Is it possible to configure it for all pipelines and all stages at once?
Post Go 14.3 you can add notifications for all pipelines and all stages at once. You would need to select the option similar to the one shown in the image below:
You could refer to the documentation for more details.