16

Is it possible to set branch policies across all repo's? In other words, When creating a branch, a default branch policy is already set for master.

Igor
  • 323
  • 2
  • 13

3 Answers3

9

It's been changed now. So for others who look for it, you can find it there:

  1. *Project Settings
  2. 'Repositories'
  3. All repositories -> 'Policies' tab
  4. On the bottom there should be 'Branch policies' section with '+' button

Screen from the mentioned view

codeedward
  • 116
  • 1
  • 5
7

Indeed as @Thomas Harris mentioned in the comment above, you can set it for all repos in a single project via

  1. **Project Settings*
  2. Cross-repo policies under "Repos" heading
  3. Click Add branch protection button

And then you can select whether this applies to the default branch or a specific branch name pattern.

Set project-wide branch protection via Project Settiongs

julie-ng
  • 500
  • 6
  • 11
6

Right now you can't. You could listen to events in Azure DevOps for project creation for example and then set the policy yourself. For some information how to start see here: https://learn.microsoft.com/en-us/azure/devops/repos/git/create-pr-status-server-with-azure-functions?view=vsts

Rob Bos
  • 1,320
  • 1
  • 10
  • 25
  • @jessehouwing has documented a way to achieve this through the API: https://jessehouwing.net/azure-repos-git-configuring-standard-policies-on-repositories/ – mhu Feb 04 '20 at 10:22
  • 1
    It is now possible to set global branch policies in the settings area for the project. Although I cannot find good documentation for this process. – Thomas Harris May 27 '20 at 06:33
  • 1
    Hi Thomas, you can find it under "cross-repo policies" and yes, it is poorly documented. Thanks for pointing that out. I will pass that along as feedback – julie-ng May 29 '20 at 06:32