The build validation for PR has started when I do a merge in ADO

76 Views Asked by At

I have a sprint95 branch in Azure DevOps, in this branch I have configured Build Validation with my pipeline from a yml file that validates the code before pull request to the sprint95 branch. enter image description here However, there is a problem that this pr-unit-test-approvement check is triggered just as soon as the merge happens (e.g. into the master branch or another branch). enter image description here

Or other example (this all from list pr-unit-test-approvement pipeline) enter image description here

I've spent a day and a half, but still haven't found what would make the code check setup for pull request for merge start. Please help with some advice. How to exclude merge validation?

1

There are 1 best solutions below

1
Alvin Zhao - MSFT On

Per this build in the screenshot, it was triggered by CI - the commit 3cee7485 pushed to the master branch rather than the PR from Branch Spint95. As soon as the code of a PR (2952) was merged into the target branch master, it pushed a commit (3cee7485) onto the target branch. enter image description here

And if any of your pipelines' reference .yml file from master branch enables CI trigger, it will be triggered by any commit (including merge commit) pushed to master. enter image description here

If you don’t want this pipeline to be triggered by commits pushed to master branch, please disable the CI trigger in the reference .yml file from master branch by updating trigger: none. But this can only take effect on master branch not all branches. You can use PR to spread this update of the .yml files onto other branches.

enter image description here

As another convenient option, you may use the pipeline's trigger settings in web UI to override the YAML CI trigger and to disable CI trigger for all branches or enable CI trigger for selected branch(es). enter image description here