DEV Community

Simon Foster
Simon Foster

Posted on • Originally published at funkysi1701.com

Azure DevOps Release Pipelines Pre and Post Approval

Azure DevOps release pipelines have lots of options to do things how you want. One of my favourites is the option for approval.

There are two ways you can do approvals Pre and Post deployment. Lets look at both.

Pre Deployment Approval

image

Lets imagine you have a simple deployment pipeline that deploys to a test/development environment before deploying to a production environment.

Pre Deployment Approval happens immediately before the release so in this example, click in the ellipse before the Prod release step.

You will get a screen like the above, you can select what users need to approve it and how long approval waits before timing out, the default is 30 days, but I tend to use a shorter time out of 3 days.

Post Deployment Approval

image

Post Deployment Approval happens immediately after the release so in this example, click in the circle after the Test release step.

You will get a screen like the above, with the same settings as before.

That is pretty much all there is to approvals so either option will prompt you to approve before anything gets deployed to your production environment.

Deployment Hours

To complicate matters I make use of the following setting to define deployment hours.
image

This setting will start the Prod deployment at 3am Mon-Fri.

If I configure Post Deployment Approval, as soon as my deploy to Test has completed a request for Approval is sent.

If I configure Pre Deployment Approval, at 3am Mon-Fri a request for Approval is sent (not ideal if you tend to be asleep at 3am)

So it looks like Post Deployment Approval is more useful for my use case. However if you deny approval either in Pre or Post approval this will mark the deployment as failed and show Red in your list of deployments.

image

From a casual glance it looks like the deployment to Test is failing, it isn't I am just opting to not continue my deployment to production.

My Pipeline

image

This is how I have my pipeline setup. Deployment happens on Test and doesn't have a post approval step.

After Test an empty stage called Approval runs and that has a post deployment approval, this happens immediately after Test so you get asked straight away for approval.

Prod does not start as I have my deployment hours configured. Once it is time for deployment to Prod to start it executes.

Now a casual look at my past releases, you can easily see which have been stopped by approval and which have failed due to whatever issue, and which have run all the way through to Prod.

And deployments to Prod can only ever run during my defined deployment window.

I am interested to hear how you have your deployment pipeline setup. Do you make use of Pre or Post Approvals? Do you ensure deployments always happen at specific times?

Top comments (0)