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
Update your YAML deployment job to include an "Environment". Please note that only deployment jobs can have an environment set.
- stage: deploy jobs: - deployment: DeployWeb displayName: Deploy Web App environment: YourApp-QA pool: vmImage: 'Ubuntu-latest'
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.
Head to Pipelines > Environments and double-check that your environment has been created.
Step 2: Setup Your Approvals & Checks
Within Azure DevOps head to Pipelines > Environments
Click on the application you've created (YourApp-QA)
Click the "..." in the upper right-hand corner
Choose "Approvals and Checks"
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
After step 3, your approval is created. To test it, rerun your pipeline and let it proceed until it reached the deployment stage.
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
Approvals & Checks Deep Dive: https://docs.microsoft.com/en-us/azure/devops/pipelines/process/approvals?view=azure-devops&tabs=check-pass
Comments