KIRY4
KIRY4

Reputation: 43

How completely protect/block branch in Azure Devops from Pull requests

I found how to block/protect branch from pushes, force pushes but how to protect branch from pull requests? When somebody creates pull requests branch merges with branch which locked (f.e. master branch) without any problems or acknowledges. How to protect branch from pull request Of course if it possible?

Branch lock (protect branch from pushes); Branch security (deny force pushes)

I want to make impossible to complete pull request to locked branch. Of course if it possible.

Upvotes: 1

Views: 10350

Answers (3)

KIRY4
KIRY4

Reputation: 43

Hm strange. Because in our case lock not preventing from PR.

Probably it depends on who made PR. His privileges in Project but I'm not sure... master branch lock

successfull PR

Upvotes: 1

Hugh Lin
Hugh Lin

Reputation: 19451

I tested locking a branch, the result of the test is that it can successfully prevent other users from completing the pull request and merge to the target branch.

When I lock the master branch, and then create pr from the dev branch to the master branch, when I click complete, I will be prompted to stop me from completing the pr. enter image description here

In addition, locking the branch can also prevent me from committing to the locked branch. enter image description here

So I think locking branch can meet your need.For details ,please refer to this official document.

Upvotes: 3

Michal Dobrzycki
Michal Dobrzycki

Reputation: 168

Plainly block branch from any PR isn't possible as a singular feature. But you can use branch policies to achieve something alike.

ADO docs says you can set policies:

  • Add specific person as required approver (it can be you)
  • Require minimum number of reviewers (you can add 999 person)
  • Check for linked work items
  • Require approval from external services (via API)

Plain locking branch forever and whatever happens is not the best approach (you want to have opportunity to do that sometimes). Hope that helps.

Upvotes: 3

Related Questions