How to add a manual intervention step in Azure Pipelines yaml

Microsoft have now made available a brand new official Manual Validation task that allows for manual intervention to be added into a YAML pipeline.

Quick example of how to use this task is as follows:

  jobs:  
  - job: waitForValidation
    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: |
          [email protected]
          [email protected]
        instructions: 'Please validate the build configuration and resume'
        onTimeout: 'resume'

Some key constraints to be aware of:

  • This task is only supported in YAML pipelines
  • Can be used only in an agentless job of a YAML pipeline.

This doesn't appear to be available yet, but there is a GitHub Issue tracking this: https://github.com/MicrosoftDocs/vsts-docs/issues/4241

From the issue:

So what I heard from the product team is that this "approval per stage" policy isn't available yet but is on their backlog.

There is also a Roadmap work item tracking it: https://dev.azure.com/mseng/AzureDevOpsRoadmap/_workitems/edit/1510336/


Azure DevOps/Pipelines now has a feature called Environments which supports approvals. https://docs.microsoft.com/en-us/azure/devops/pipelines/process/environments?view=azure-devops#approvals

We are using them as a workaround. Basically we have specified two environments ApprovalNotRequired and ApprovalRequired in Azure DevOps. On the latter we have specified who can approve deployments. Then in the pipeline we reference the environment like this.

- stage: 'Approval not required'
  jobs:
  - deployment: 'MyDeployment'
    displayName: MyDeployment
    environment: 'ApprovalNotRequired'
    strategy:
      runOnce:
        deploy:
          # whatever

- stage: 'Approval required'
  jobs:
  - deployment: 'MyDeployment2'
    displayName: MyDeployment2
    environment: 'ApprovalRequired'
    strategy:
      runOnce:
        deploy:
          # whatever

The first stage will run without interference and the second will pause until it's approved.