Search code examples
azure-devopsazure-pipelines

Step references task 'ManualValidation' at version '0.238.0' which is not valid for the given job target


I am trying to add the manual validation task in the below pipeline code, however every time it is throwing the same message. Read few other articles where it has been said try using pool: server, but then there is a problem like i want all my tasks like terraform install, init, plan and apply should run on the self hosted agent which i have created.

Below is my pipeline:

    trigger:
      branches:
        include:
          - none
    
    pool: terraform-vm
    
    stages:
     - stage: "Independent"  
       jobs: 
       - job: ""
    
     - template: template/terraform.yaml

Below is my terraform.yaml template, which is being called by my pipeline.

    stages:
    -   stage: "TF_tasks"
        condition:  and(succeeded(), or(eq(variables['Build.SourceBranchName'], 'main'), eq(variables['Build.SourceBranchName'], 'dev'), eq(variables['Build.SourceBranchName'], 'uat')))
        displayName: "Terraform tasks"
        jobs:
          - deployment: DeploymentToDev
            displayName: 'Deploy To Dev'
            condition: eq(variables['Build.SourceBranchName'], 'dev')
            environment: 'dev'
            strategy:
              runOnce:
                deploy:
                  steps:
                    - task: TerraformInstaller@1
                      inputs:
                          terraformVersion: 'latest'
    
                    - task: TerraformTaskV4@4
                      displayName: "Terraform Init"
                      inputs:
                          provider: 'azurerm'
                          command: 'init'
                          workingDirectory: '$(Pipeline.Workspace)/s'
                          backendServiceArm: 'xxxxxxxxx'
                          backendAzureRmResourceGroupName: 'xxxxxxxxxxxxx'
                          backendAzureRmStorageAccountName: 'xxxxx'
                          backendAzureRmContainerName: 'xxxxxxxxxx'
                          backendAzureRmKey: 'xxxxxxxxxxxx'
              
                    - task: TerraformTaskV4@4
                      displayName: "Terraform_validate"
                      inputs:
                          provider: 'azurerm'
                          command: 'validate'
                          environmentServiceNameAzureRM: 'xxxxxxxxxxxxx'
                          workingDirectory: '$(Pipeline.Workspace)/s'
    
    
                    - task: TerraformTaskV4@4
                      displayName: "Terraform plan"
                      inputs:
                          provider: 'azurerm'
                          command: 'plan'
                          workingDirectory: '$(Pipeline.Workspace)/s'
                          commandOptions: '-var-file=tfvars/dev.tfvars'
                          environmentServiceNameAzureRM: 'xxxxxxxxxxxxx'
                    
                    - task: ManualValidation@0
                      timeoutInMinutes: 5
                      inputs:
                        notifyUsers: "xxxxxxxxxxxxxxx"
    
                    - task: TerraformTaskV4@4
                      displayName: "Terraform Apply"
                      inputs:
                          provider: 'azurerm'
                          command: 'apply'
                          workingDirectory: '$(Pipeline.Workspace)/s'
                          commandOptions: '-var-file=tfvars/dev.tfvars'
                          environmentServiceNameAzureRM: 'xxxxxxxxxxxxxx'

Solution

  • Refer to this doc: ManualValidation@0 - Manual validation v0 task

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

    When you use the ManualValidation@0 task in YAML pipeline, you need to use agentless jobs. This is an expected behavior.

    For example:

    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: |
            test@test.com
            example@example.com
          instructions: 'Please validate the build configuration and resume'
          onTimeout: 'resume'
    

    i want all my tasks like terraform install, init, plan and apply should run on the self hosted agent which i have created.

    Since the ManualValidation task needs to be run in an agentless job, I'm afraid your requirement cannot be achieved now.

    You need to use agentless job to run ManualValidation and self-hosted agent job to run other terraform tasks.

    On the other hand, there is no other tasks can add manual approval during the single agent job running process.

    I can fully understand your requirement. You can submit a suggest ticket in the site: Developer Community to report this feature