We have Azure DevOps Repo, where want to run the pipline as soon as the PR is complete i.e we merge the changes We are using below script:
# Define trigger for the pipeline
trigger:
branches:
include:
- Development
- QualityAssurance
- Production
paths:
include:
- '*'
variables:
- group: 'GroupNames'
# Define stages for Dev, QA, and Prod
stages:
- stage: Development
displayName: 'Dev'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/Development'))
jobs:
- template: ./deploy-files-template.yaml
parameters:
azureSubscription: 'xxx'
poolname: 'Dev-Ubuntu-20.04'
vargroup: 'GroupNames'
inlineScript: 'az storage blob upload-batch -d "$(abcabc)" --account-name "$(abcabc)" -s "$(Build.Repository.LocalPath)/repos/" --account-key "$(abcabc)" --overwrite'
- stage: QualityAssurance
displayName: 'QA'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/pull/*/merge'), eq(variables['System.PullRequest.TargetBranch'], 'refs/heads/QualityAssurance'))
jobs:
- template: ./deploy-files-template.yaml
parameters:
azureSubscription: 'Momenttum_QA_SPN-RESRVOIR DATA Project'
poolname: 'QA-Ubuntu-20.04'
vargroup: 'QNames'
inlineScript: 'az storage blob upload-batch -d "$(abcabc)" --account-name "$(abcabc)" -s "$(Build.Repository.LocalPath)/repos/" --account-key "$(abcabc)" --overwrite'
What do we need to do if we want to run the pipeline as soon as a PR is completed,
We tried using pr: but it does not seems to work
can some suggest please?
2
Answers
Add the merge target branch to the
branches
section of yourtrigger
.Assuming that you are merging to one of the given branches
Development
,QualityAssurance
,Production
,The configuration given seems correct, but there are couple things to double-check: