7

My understanding is that branch policies allow us to prevent push to master but allow PR. But I could not find a policy or security settings on Azure DevOps that allow me to do this. What am I missing?

riQQ
  • 9,878
  • 7
  • 49
  • 66
Blue Clouds
  • 7,295
  • 4
  • 71
  • 112

1 Answers1

7

After you set up a required branch policy, you can't directly push changes to the branch. Changes to the branch are only made through pull requests. You can refer to this documentation:

A branch that has required policies configured can't be deleted, and requires pull requests (PRs) for all changes.

You can't push changes directly to branches that have required branch policies unless you have permissions to bypass branch policies. Changes to these branches can be made only through pull requests. You can push changes directly to branches that have optional branch policies, if they have no required branch policies.

Please note that:

  • If you have permissions that allow you to bypass branch policies you can push directly to a branch after a required branch policy is configured.
  • If you configured optional branch policies, but no required branch policies, you can push changes directly to a branch.

For example: If the policy requirement here is optional, you can still push changes directly to the branch. If the policy requirement here is required, you need to create a pull request to push changes.

enter image description here

riQQ
  • 9,878
  • 7
  • 49
  • 66
Walter
  • 2,640
  • 1
  • 5
  • 11
  • 1
    So a byproduct of setting any branch policy is to prevent push to Master? – Blue Clouds Jan 15 '21 at 09:27
  • 1
    @BlueClouds Not all branch policies but required branch policies. Please refer to the sample in my answer. – Walter Jan 15 '21 at 09:40
  • 3
    So to repeat the question, a byproduct of setting any branch policy is to prevent push to Master? I'm asking the identical question because there is nothing at all on that policy page that indicates the policy will prevent people from pushing to Master. This is confusing because in your example, it says "Build failure will not block completion..." What we are referring to has nothing to do with build failures. I have 0 build failures, but it won't let me push to Master of my own repo in which I am the project admin. This is so aggravating. The descriptions on that page are atrocious. – Bryan Williams Sep 19 '22 at 18:09
  • They say a good UI doesn't need much documentation. I guess that Microsoft are trying to pretend that DevOps has a good UI by not providing good documentation. – Paul McCarthy Jun 26 '23 at 14:24