On Azure devops you have the option to create both build and release pipelines. The build pipelines can be created using entirely the .yml notation in comparison with the release pipelines which should be created using a GUI. Build and release pipelines have their differences when it comes to approvals.
For release pipelines in order to create an approval flow you need to navigate in the stage and click the thunder strike. There you can locate the pre-deployment approvals and also gates that can be configured for that stage.
You can also define post-deployment approvals by clicking the person icon on the stage.
On the other hand in order to create approvals on build pipelines you will need to first create an environment. From environments you need to create a new blank environment
Then you need to navigate inside the environment and select approvals and checks
The last step would be to create a deployment job through YAML and point that environment. Every job which is created as deployment and has the environment configured will go through the approvals configured.
Lets see for example the below pipeline:
trigger: none pool: vmImage: ubuntu-latest stages: - stage: stage1 displayName: stage1 jobs: - deployment: job1 displayName: job1 environment: appservice-west strategy: runOnce: deploy: steps: - task: PowerShell@2 displayName: run powershell 1 inputs: targetType: 'inline' script: | Write-Host "Hello from powershell 1" - stage: stage2 dependsOn: stage1 displayName: stage2 jobs: - deployment: job2 displayName: job2 environment: appservice-west strategy: runOnce: deploy: steps: - task: PowerShell@2 displayName: run powershell 2 inputs: targetType: 'inline' script: | Write-Host "Hello from powershell 2"
Before the execution of job1 and job2 an approval will be asked the way it is configured from the environment.