How to use the Manual Validation task in Azure DevOps pipeline?
Solution 1:
I think your problem is that you actually have to jobs in your pipeline, as the yaml template has a job specified in it. Haven't actually tested it, but I would think that the manual validation step in first job only applies in that job, and the another job starts regardless.
There are probably multiple ways to solve the problem (by adding DependsOn-clause and/or changing the template to only have steps), but I would actually suggest adding an environment in Azure DevOps (under Pipelines -> Environments, let's call it 'Production' for now), adding manual approval to that environment, and changing the Prod-stage and jobs to be a deployment job that targets the 'Production'-enviroment.
So something like:
- stage: Prod
displayName: "Deployment: Production"
dependsOn: QA
jobs:
- deployment: deploy_prod
displayName: Deploy Production
pool: server
condition: and(succeeded('QA'), eq(variables['Build.SourceBranch'], 'refs/heads/release'))
environment: Production
strategy:
runOnce:
deploy:
steps:
- template: build-and-deploy-stage.yml
parameters:
targetEnv: 'Prod'
dataset: 'prod'
token: $(deploymentTokenProd)
And template with just steps:
parameters:
- name: targetEnv
type: string
- name: dataset
type: string
- name: token
type: string
steps:
- task: NodeTool@0
displayName: 'Install Node LTS'
inputs:
versionSpec: '14.18.x'
# … not relevant but using parameters.dataset and parameters.token
https://docs.microsoft.com/en-us/azure/devops/pipelines/process/environments?view=azure-devops
https://docs.microsoft.com/en-us/azure/devops/pipelines/process/deployment-jobs?view=azure-devops
Solution 2:
I've ended up using dependsOn
on the job.