Thursday 14 January 2021

New Manual Validation Task for YAML Pipelines

Even though YAML pipelines could be setup to wait for approvals based on environment approvals and checks, setting up a manual intervention task which was available to classic release pipelines, was not supported in YAML deployment pipelines till the latest feature release to Azure DevOps. With the introduction of new Manual Validation Task specifically supporting only YAML pipelines, now you can wait for resume/reject with an agentless job, during the YAML pipeline execution. Let’s look at how this new task works.


The task in action would look like as shown below. The manual validation here waits for confirmation on the correct release number is applied or not, based on the utilized build in the deployment, which might help preventing accidentally, deploying package with a wrong build as input to the deployment pipeline setup in YAML.


Once click on review you can decide to resume or reject the pipeline based on manual validations performed.


The code is setup for this one pipeline as below. Manual validation task is set to run only when the release number setup job is completed, using a depends on, to ensure the notification for manual validation only sent after the release number is set. The time out of the manual validation agent less job should be higher than the manual validation task to run completely. The agentless job is set by setting the pool to server. Once the validation task timeout hit the default action would be to reject. You can set it to resume automatically by setting up onTimout option as resume.


Following is the job code of the manual validation task.

- job: ValidateReleaseNumber
      displayName: Wait for Validate Release Number
      dependsOn: SetReleaseNumber
      pool: server
      timeoutInMinutes: 4320 # 3 days
      steps:
      - task: ManualValidation@0
        timeoutInMinutes: 2880 # 2 days
        inputs:
          instructions: 'Check release number'
          notifyUsers: 'chaminda_chandrasekara@yahoo.com'
          onTimeout: reject

Following is the entire pipeline code.

resources:
  pipelines:
  - pipeline: App_CI 
    projectYAML_CICD
    source: App.CI 
    trigger: true

pool:
  vmImage: 'windows-latest'

stages:
- stage: PreDeploy
  jobs:
    - job: SetReleaseNumber
      displayName: Set Release Number
      steps:
        - pwsh: |
              $releaseName = '$(resources.pipeline.App_CI.runName)' + '-' + $(Build.BuildId)
              Write-Output "##vso[build.updatebuildnumber]$releaseName"
    - job: ValidateReleaseNumber
      displayName: Wait for Validate Release Number
      dependsOn: SetReleaseNumber
      pool: server
      timeoutInMinutes: 4320 # 3 days
      steps:
      - task: ManualValidation@0
        timeoutInMinutes: 2880 # 2 days
        inputs:
          instructions: 'Check release number'
          notifyUsers: 'chaminda_chandrasekara@yahoo.com'
          onTimeout: reject

- stage: Dev
  displayName: Deploy to Dev
  jobs:
  - deployment: DeployDev
    environment: myapp-dev
    strategy:
       runOnce:
        deploy:
          steps:
          - pwsh: |
              Write-Host ('some deployment steps')

You can search for this new manual validation task in Azure DevOps web UI while editing a pipeline as shown below.

Then can fill the details and get it added to pipeline.


If you are using the manual validation task and if the pipeline stage has more than one job to perform, make sure to set the dependencies correctly. Else for example if the release number job is not set as a dependency in the case scenario in this blog, the manual validation notification is sent before even setting the release number.

No comments:

Popular Posts