Srinivas Charan Mamidi
Srinivas Charan Mamidi

Reputation: 321

How to add Post deployment approvals in multistage YAML pipeline?

I have a multistage YAML pipeline with three QA stages QA1,QA2,QA3 . I have to add post deployment approval to QA3, i.e, once QA3 finishes successfully, it must wait for my approval to trigger stage PROD deployment. how to achieve this ?

Upvotes: 0

Views: 1980

Answers (2)

Kevin Lu-MSFT
Kevin Lu-MSFT

Reputation: 35514

Based on your requirement, you could try to use the Environment in your YAML Sample.

Here are the steps:

Step1: Create Environment in Pipelines -> Environments and add Approvals and checks.

enter image description here

Step2: Add Environment in YAML Pipeline.

stages:
- stage: QA1
  jobs:
  - job: QA1
    steps:
      - script: echo 1

- stage: QA2
  jobs:
  - job: QA2
    steps:
      - script: echo 1

- stage: QA3
  jobs:
  - job: QA3
    steps:
      - script: echo 1

- stage: deploy
  jobs:
  - deployment: DeployWeb
    displayName: deploy Web App
    pool:
      vmImage: 'Ubuntu-latest'
    environment: 'Test'
    strategy:
      runOnce:
        deploy:
          steps:
          - script: echo Hello world

Result:

enter image description here

Upvotes: 3

Krzysztof Madej
Krzysztof Madej

Reputation: 40849

There is no post deployment approval. What you can do is ManualValidation

- stage: CI
  jobs:
  - job: CI
    steps:
    - script: echo 'From CI'

- stage: UAT
  jobs:
  - job: UAT
    steps:
    - script: echo 'From UAT'
  
  - job: UATWaitForValidation
    displayName: Wait for external validation  
    pool: Server
    timeoutInMinutes: 4320 # job times out in 3 days
    steps:
    - task: ManualValidation@0
      timeoutInMinutes: 1440 # task times out in 1 day
      inputs:
        notifyUsers: $(users)
        instructions: 'Please validate the build configuration and resume'
        onTimeout: 'resume'

- stage: PROD
  jobs:
  - job: PROD
    steps:
    - script: echo 'From PROD'

Upvotes: 1

Related Questions