Have you ever wondered how Azure DevOps knows whether to proceed with deployment in a YAML pipeline?
In real-world projects, especially when deploying to a ๐ฃ๐ฟ๐ผ๐ฑ๐๐ฐ๐๐ถ๐ผ๐ป ๐ฒ๐ป๐๐ถ๐ฟ๐ผ๐ป๐บ๐ฒ๐ป๐, approvals play a crucial role in maintaining control and preventing accidental releases.
Hereโs what I learned and implemented:
โ ๐ฆ๐๐ฒ๐ฝ-๐ฏ๐-๐๐๐ฒ๐ฝ ๐๐ป๐ฑ๐ฒ๐ฟ๐๐๐ฎ๐ป๐ฑ๐ถ๐ป๐ด:
- Define an environment (e.g.,
Production
) in your YAML pipeline using theenvironment
keyword. - Go to ๐ฃ๐ถ๐ฝ๐ฒ๐น๐ถ๐ป๐ฒ๐ โ ๐๐ป๐๐ถ๐ฟ๐ผ๐ป๐บ๐ฒ๐ป๐๐ โ ๐ฃ๐ฟ๐ผ๐ฑ๐๐ฐ๐๐ถ๐ผ๐ป in Azure DevOps.
- Set ๐ฝ๐ฟ๐ฒ-๐ฑ๐ฒ๐ฝ๐น๐ผ๐๐บ๐ฒ๐ป๐ ๐ฎ๐ฝ๐ฝ๐ฟ๐ผ๐๐ฎ๐น๐ by adding the required approvers.
- When the pipeline reaches that stage, Azure DevOps automatically ๐ฝ๐ฎ๐๐๐ฒs and sends an approval request.
- If the request is ๐ฎ๐ฝ๐ฝ๐ฟ๐ผ๐๐ฒ๐ฑ, the pipeline continues and deploys to Production.
- If the request is ๐ฟ๐ฒ๐ท๐ฒ๐ฐ๐๐ฒ๐ฑ, the deployment stops โ no manual intervention needed in YAML.
๐ง ๐ฆ๐ฎ๐บ๐ฝ๐น๐ฒ ๐ฌ๐๐ ๐ ๐๐ป๐ถ๐ฝ๐ฝ๐ฒ๐:
stages:
- stage: ProductionDeployment
displayName: 'Deploy to Production'
dependsOn: Build
environment: 'Production'
jobs:
- deployment: DeployToProd environment: 'Production' strategy: runOnce: deploy: steps: - script: echo "Deploying to Production after approval"
Azure DevOps takes care of checking whether the approver has approved or rejected โ you donโt need to write extra logic for this in the YAML file.
๐๐ผ๐ ๐ฑ๐ผ ๐๐ผ๐ ๐บ๐ฎ๐ป๐ฎ๐ด๐ฒ ๐ฎ๐ฝ๐ฝ๐ฟ๐ผ๐๐ฎ๐น๐ ๐ฎ๐ป๐ฑ ๐ฑ๐ฒ๐ฝ๐น๐ผ๐๐บ๐ฒ๐ป๐๐ ๐๐ผ ๐ฃ๐ฟ๐ผ๐ฑ๐๐ฐ๐๐ถ๐ผ๐ป ๐ถ๐ป ๐๐ผ๐๐ฟ ๐๐/๐๐ ๐ฝ๐ถ๐ฝ๐ฒ๐น๐ถ๐ป๐ฒ๐? ๐๐ผ ๐๐ผ๐ ๐ฟ๐ฒ๐น๐ ๐ผ๐ป ๐ฒ๐ป๐๐ถ๐ฟ๐ผ๐ป๐บ๐ฒ๐ป๐๐ ๐ถ๐ป ๐๐๐๐ฟ๐ฒ ๐๐ฒ๐๐ข๐ฝ๐ ๐ผ๐ฟ ๐ณ๐ผ๐น๐น๐ผ๐ ๐ฎ ๐ฑ๐ถ๐ณ๐ณ๐ฒ๐ฟ๐ฒ๐ป๐ ๐ฎ๐ฝ๐ฝ๐ฟ๐ผ๐๐ฎ๐น ๐ฝ๐ฟ๐ผ๐ฐ๐ฒ๐๐?
Top comments (0)