Search code examples
azure-devopsbranchbranching-and-mergingpolicy

Is there a way to restrict PRs from a specific branch to another in Azure DevOps


I'm trying to find a way to restrict a PR creation from something starting with feature/xxxx to release/xxxxx ( or in a simpler way, from feature branch to release branch) in Azure DevOps. A workaround might be filtering the path in build validation of branch policy as mentioned here, but it needs a build pipeline for this. Is there any other way that this can be done? I know about these two predefined variables in Azure DevOps: System.PullRequest.TargetBranch, System.PullRequest.SourceBranch but then again these are only available for yaml pipeline. I'm pretty new with this. Can anyone help?


Solution

  • Unfortunately, there is no permission to restrict PRs. The only way is set branch policies to protect target branch. You can use the workaround you mentioned, or you could add required reviewer for the affected path:

    enter image description here