top of page
Writer's pictureMax Morrow

Azure DevOps: Setting Pre-Deployment Approvals for YAML Pipelines

Updated: Jul 11, 2021

If you're creating a pipeline that is deploying to many environments, including production, chances are that you're looking to set up stage gates. If you're used to Classic Releases within Azure DevOps, Microsoft has changed how you go about configuring pre-deployment approvals. Let's dive into how to set them up.


NOTE: Unlike Classic pipelines, you cannot specify environment approvals within your pipelines themselves. You need to first create a pipeline and specify environments. Approvals are applied to environments, not pipelines.


Step 1: Create your pipeline & environment

  1. Update your YAML deployment job to include an "Environment". Please note that only deployment jobs can have an environment set.

    1. - stage: deploy jobs: - deployment: DeployWeb displayName: Deploy Web App environment: YourApp-QA pool: vmImage: 'Ubuntu-latest'

  2. Push your changes to your pipeline and rerun your build/deployment or head to Pipelines > Environments to create your environment (YourApp-QA) in this instance.

  3. Head to Pipelines > Environments and double-check that your environment has been created.

Step 2: Setup Your Approvals & Checks

  1. Within Azure DevOps head to Pipelines > Environments

  2. Click on the application you've created (YourApp-QA)

  3. Click the "..." in the upper right-hand corner

  4. Choose "Approvals and Checks"

  5. Click Approvals:

6. Add the users, or groups, that you want to have access to approving a pipeline

7. Click "Create"


Step 3: Testing Your Approval

  1. After step 3, your approval is created. To test it, rerun your pipeline and let it proceed until it reached the deployment stage.

  2. When it reaches the deployment stage configured to use your environment (Deploy Web App), the deployment will stop and wait for approval:


Troubleshooting: If your pipeline did not stop and wait for approval check to ensure that your pipeline has the correct spelling of the environment and that the environment is specified on a deployment job.



Bonus: Additional Resources


1,956 views0 comments

Comments


bottom of page