I have successfully created a CI/CD pipeline for Azure Data Factory with Azure DevOps using yaml templates, see below. This in contrast to creating the same pipelines using Azure DevOps ‘Classic Editor’
When creating Build/Release pipelines using Classic Editor I have the option to create Pre-Deployment options such as shown in the image – in particular I would like to setup ‘Pre-deployment approvals.
Is there a similar option to choose Pre-deployment approvals from any of the following yaml templates:
My yaml code is as follows:
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml
trigger:
- adf_publish
pool:
vmImage: ubuntu-latest
steps:
- script: |
tree $(System.DefaultWorkingDirectory)
displayName: Show file structure of System.DefaultWorkingDirectory during a build
- task: AzurePowerShell@5
inputs:
displayName: PreDeployment
azureSubscription: 'NewConnectionName'
ScriptType: 'FilePath'
ScriptPath: '$(System.DefaultWorkingDirectory)/caplogic-warehouse-dev-df/PrePostDeploymentScript.ps1'
ScriptArguments: '-armTemplate "$(System.DefaultWorkingDirectory)/caplogic-warehouse-dev-df/ARMTemplateForFactory.json" -ResourceGroupName $(ResourceGroup) -DataFactoryName $(DataFactory) -predeployment $true -deleteDeployment $false'
azurePowerShellVersion: 'LatestVersion'
- task: AzureResourceManagerTemplateDeployment@3
inputs:
deploymentScope: 'Resource Group'
azureResourceManagerConnection: 'NewConnectionName'
subscriptionId: '5fa2700d-738a-444e-a643-28241a29d08d'
action: 'Create Or Update Resource Group'
resourceGroupName: '$(ResourceGroup)'
location: '$(Location)'
templateLocation: 'Linked artifact'
csmFile: '$(System.DefaultWorkingDirectory)/caplogic-warehouse-dev-df/ARMTemplateForFactory.json'
csmParametersFile: '$(System.DefaultWorkingDirectory)/caplogic-warehouse-dev-df/ARMTemplateParametersForFactory.json'
overrideParameters: '-factoryName $(DataFactory)'
deploymentMode: 'Incremental'
- task: AzurePowerShell@5
inputs:
azureSubscription: 'NewConnectionName'
ScriptType: 'FilePath'
ScriptPath: '$(System.DefaultWorkingDirectory)/caplogic-warehouse-dev-df/PrePostDeploymentScript.ps1'
ScriptArguments: '-armTemplate "$(System.DefaultWorkingDirectory)/caplogic-warehouse-dev-df/ARMTemplateForFactory.json" -ResourceGroupName $(ResourceGroup) -DataFactoryName $(DataFactory) -predeployment $false -deleteDeployment $true'
azurePowerShellVersion: 'LatestVersion'
I was thinking that one of the following task could be used to pause a the pipeline until some intervention was approved
But I couldn’t get either of the above to tasks to work inside my yaml
I get the error
Job Job: Step references task 'ManualIntervention' at version '8.238.0' which is not valid for the given job target.
I have tried the following yaml code I found online
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]
instructions: 'Please validate the build configuration and resume'
onTimeout: 'resume'
But I get the following error:
/caplogic-warehouse-dev-df/azure-pipelines-5.yml (Line: 77, Col: 1): Unexpected value 'jobs'
I have updated the yaml code to reflect the code that @Vlad kindly helped me with:
trigger:
- adf_publish
pool:
vmImage: ubuntu-latest
steps:
- script: |
tree $(System.DefaultWorkingDirectory)
displayName: Show file structure of System.DefaultWorkingDirectory during a build
- task: ManualValidation@0
timeoutInMinutes: 1440 # task times out in 1 day
inputs:
notifyUsers: |
[email protected]
instructions: 'Please validate the build configuration and resume'
onTimeout: 'resume'
However, I’m still getting the error:
Job Job: Step references task 'ManualValidation' at version '0.238.0' which is not valid for the given job target.
There is probably something very obvious that I’m missing, but I can’t see it.
2
Answers
For
ManualValidation
you have used a snippet with structure:But in your original pipeline you only have structure:
If in the beginning of the pipeline definition you use
steps
withoutstages
andjobs
, it means that you are implicitly skipping thejobs
level and define only one single job.You should check out key concepts of Azure Pipelines to understand it better.
Key concepts
Something like this should work:
In YAML pipelines, you can configure manually approvals like as below:
If the stage contains deploy jobs that need to target to environments, You can directly set approvals on the environments. If you have set multiple approval checks on the environment, you can change execution order of the checks to let then evaluate as
Pre-check approval
orPost-check approval
.If the stage does not contain any deploy jobs, you can configure a Server job (Agentless job) to run the
ManualValidation@0
task.ManualValidation@0
task in the Server job to pause a the YAML pipeline run to wait for manual approval.