Wednesday 8 July 2020

Cross Repo Branch Policies in Azure Git Repos

Azure Git repos provide protection to branches with branch policies. The cross-repo branch policy in a team project now lets you define policies applicable to a branch pattern, where it would even be applied to future branches which are adhering to the specified pattern. Let’s explore this feature in bit of detail.
In the team project settings page, now you get all repositories policies tab, where you can define branch policies effective to all repos in the team project.

You can apply policy to protect default branch in each repo. Or you can define a pattern, which will protect the current and future branches matching the pattern. Currently available branches matching the pattern in each repo in the team project will be listed as you type in the pattern.

Then you can create the branch policy for the given pattern as normal branch protection policy in Azure Git repo. Which can even include reviewers, build policies etc.

The policies will be applied to any branch meeting the pattern in any repo in the team project.

This feature is really useful when you have a single repo in a team project to auto apply the policies. Multiple repos in single project get the policies applied but the build policies have to be controlled with path filters in project level using cross project policies, or use inherited policies combined with individual repo branch level build policies. However, that will require the build policies to be applied to each new branch created.
Ideally, a feature to apply pattern based policies to single repo within a team project, with the option to decide cross repo policy inheritance to be overridden would be greatly benefiting the maintenance of branch protection policies in Azure Git repos.

No comments:

Popular Posts