In Azure DevOps I am trying to run build only when code changes are approved by approver, and not automatically or manually. I have added an Environment -> Approvers and checks named 'test' and also in below yml but didnt work.
trigger:
- mainQA
pool:
vmImage: ubuntu-latest
steps:
- script: echo Hello, world!
displayName: 'Run a one-line script'
env:
ENVIRONMENT_NAME: test
To use the environment approvals you'll need to target the environment on the job level. Each job runs on a new host agent while steps run on the same host agent. Therefore approvals can't be used on steps as that would require the host agent to remain available until the approval is given.
- stage: deploy
jobs:
- deployment: Deploy
displayName: deploy hello world
pool:
vmImage: 'Ubuntu-latest'
environment:
# This should have the same name as your environment
name: 'test'
strategy:
runOnce:
deploy:
steps:
- script: echo Hello world
Link to Microsoft documentation