0
votes

I have a Multistage YAML pipeline containing two stages 1) Build and 2) Deploy. Deploy stage is mentioned below and I want to add pre deploy approvals in that stage before deploy task. How can I add pre deployment and Post deployment approvals in multistage YAML pipeline?

stages:
- stage: 'Build'

# RESTORE
   # Some task implementation
# BUILD
   # Some task implementation
# PUBLISH
   # Some task implementation

# DEPLOY STAGE
- stage: 'Dev'
  displayName: 'Deploy to the dev environment'
  dependsOn: Build
  jobs:
  - deployment: Deploy
    pool:
      vmImage: 'ubuntu-16.04'
    environment: dev
    variables:
    - group: Release
    strategy:

# HOW TO ADD PRE DEPLOYMENT AND POST DEPLOYMENT APPROVALS?

      runOnce:
        deploy:
          steps:
          - download: current
            artifact: drop
          - task: AzureWebApp@1
            displayName: 'Azure App Service Deploy: website'
            inputs:
              azureSubscription: 'Resource Manager - Tailspin - Space Game'
              appName: '$(WebAppNameDev)'
              package: '$(Pipeline.Workspace)/drop/$(buildConfiguration)/*.zip'
1
Did you figure out a way to set post deployment approvals? Me too having same problem.Garuda
No buddy. I haven't. I found out that using YAML/YML we can only set one approval which is Pre-approval. Which we can set on any Environment we want and the approval window will be shown to the user added as an approver. This is all I got.Jay Bhiyani

1 Answers

2
votes

For this issue ,currently, manual approval and evaluate artifact are the only available checks, and they can be configured on environments, service connections and agent pools only.

To define an approval on an environment:

  1. In your Azure DevOps project, go to the environment that needs to be protected. (Learn more about creating an environment.)

    enter image description here

  2. Navigate to Approvals and Checks for the environment.

    enter image description here

  3. Select Create, provide the approvers and an optional message, and select Create again to to complete addition of the manual approval check.

Then use the environment: 'xxx' parameter in your yaml file. For example:

- stage: deploy
  jobs:
  - deployment: DeployWeb
    displayName: deploy Web App
    pool:
      vmImage: 'Ubuntu-16.04'
    # creates an environment if it doesn't exist
    environment: 'multiStage'

The GUI and the yaml are interdependent in this case, it's not straight yaml.

For details ,please refer to this official document.