AzureDevOps repository medium builtIn

Description

The default branch name for all repositories should be 'main'. This policy will ensure naming convention is consistent across each repository. You can change the default branch for a particular repository at any time. Learn more: https://learn.microsoft.com/en-us/azure/devops/repos/git/repository-settings#default-branch-name https://learn.microsoft.com/en-us/azure/devops/repos/git/change-default-branch

Recommendation

1. Navigate to Project Settings. 
2. Open the Repositories link under Repos. 
3. Click on Settings tab. 
4. Under 'All Repositories Settings' section, ensure the setting 'Default branch name for new repositories' is 'main'. 
5. Navigate to Project -> Repos -> Branches 
6. Select a repository from top drop down list. 
7. Ensure the 'Default' and 'Compare' labels are for the 'main' branch.

Policy Rule

{
  "target": "ADOProjectGitRepository",
  "if": {
    "allOf": [
      {
        "resource": "ADOProjectGitRepository",
        "property": "DefaultBranch",
        "operator": "match",
        "value": "$(POLICY_VAR_REPO_DEFAULT_BRANCH_PATTERNS)"
      }
    ]
  },
  "then": {
    "effect": "Audit"
  }
}