I would like to enforce a policy on my Pull Requests in Azure Devops (using Azure Repositories) to only allow a PR to be complete IFF the build definition succeeds. Based on this documenation: https://learn.microsoft.com/en-us/azure/devops/repos/git/branch-policies?view=azure-devops and what I have tested so far the builds only trigger after the PR is marked complete. So in the event that a build failure occurs, the broken code makes it into the master (or target branch). I'd like to disable the ability to complete a PR until the Build Succeeds. This was possible in Team Foundation Server but I have not been able to set this up in Azure Devops.
I have reviewed the Branch Policies section and it is clear how to require a review/approval from a member of a specific group prior to allowing the PR to be marked Complete. So the hooks seem to exist, however, I have only been able to trigger a build definition AFTER the build is marked Complete.
The "Build Validation" section of the link you mentioned does exactly what you describe.
Set a policy requiring changes in a pull request to build successfully with the protected branch before the pull request can be completed.
edit: this is how it looks like afterwards:
Look at the section "automatically include code reviewers".
If you select Required next to a path entry, then the pull request cannot be completed until:
- Every user added as a reviewer for the path approves the changes.
- At least one person in every group added to the path approves the changes.