Azure DevOps CI/CD Approval Email Workflow Setup


Explanation of the Diagram:

  1. Actors: There are three actors: Developer (Dev), QA Approver (QA), and Prod Approver (Prod).
  2. Stages: The pipeline consists of three main stages: Build, QA, and Prod, with each stage having approval steps.
  3. Approval Flow: After each environment deployment (Dev, QA, and Prod), an approval is required before the pipeline proceeds to the next stage.
  4. Email Notification: After each approval request, an email notification is sent to the appropriate approver for approval.

To set up an approval email workflow in Azure DevOps for CI/CD across different environments (dev, qa, prod), you can define approvals and gates in your pipeline YAML file or through the Azure DevOps portal. Below is a detailed example, including an email notification configuration:

Example YAML Pipeline with Approval and Email Notification

1. Define Environments and Approvals

First, create environments for your stages (Dev, QA, and Prod) and configure approvals for each.

trigger:
- main

pool:
  vmImage: 'ubuntu-latest'

stages:
- stage: Dev
  displayName: 'Development Stage'
  jobs:
    - job: Build
      displayName: 'Build Application'
      steps:
        - task: UseDotNet@2
          inputs:
            packageType: 'sdk'
            version: '5.x'
        - script: echo 'Building the application...'
          displayName: 'Build Application'
      environment: 'dev'
      approval:
        approvals:
          - approver: 'dev@example.com'

- stage: QA
  displayName: 'QA Stage'
  dependsOn: Dev
  condition: succeeded()
  jobs:
    - job: DeployToQA
      displayName: 'Deploy to QA'
      steps:
        - script: echo 'Deploying to QA environment...'
          displayName: 'Deploy Application to QA'
      environment: 'qa'
      approval:
        approvals:
          - approver: 'qa@example.com'

- stage: Prod
  displayName: 'Production Stage'
  dependsOn: QA
  condition: succeeded()
  jobs:
    - job: DeployToProd
      displayName: 'Deploy to Production'
      steps:
        - script: echo 'Deploying to Production environment...'
          displayName: 'Deploy Application to Production'
      environment: 'prod'
      approval:
        approvals:
          - approver: 'prod@example.com'

2. Set up Email Notification for Approvals

In Azure DevOps, you can configure email notifications to be sent whenever an approval request is triggered. This can be done in the Project Settings > Notifications.

  1. Navigate to your project in Azure DevOps.
  2. Go to Project Settings > Notifications.
  3. Create a new subscription or modify the existing one to include the "Approval Required" event.
  4. Ensure the appropriate individuals (e.g., dev@example.com, qa@example.com, prod@example.com) are included in the notification list.

The notifications will automatically be sent when an approval is required at each environment (Dev, QA, Prod).

Key Points:

  • The approval section in the YAML file specifies the approver(s) for each stage.
  • The Email Notifications feature will send alerts when an approval is required. You can customize the email contents through the notification settings.
  • You can also use manual interventions in case you prefer more control over when the pipeline pauses for approvals.

This setup will trigger an email for each stage (Dev, QA, and Prod) when approval is needed, ensuring that only the designated person can approve the deployment to each environment.

Comments

Popular posts from this blog

Spring Boot OpenAI Integration: Step-by-Step Guide

Orchestration-Based Saga Architecture and Spring Boot Microservices Implementation Guide

Spring Boot 3 + Angular 15 + Material - Full Stack CRUD Application Example