简体   繁体   中英

TFS Condition pull request from specific branch

There is any way to condition a pull request to come from an specific branch on Team Foundation Server 2017 ? We are implementing gitflow and we would like to enforce pull requests to master always come from develop or hotfix branches .

I'm not sure it is possible to configure this with out-of-the-box features of TFS/VSTS. Default branching policies (as @Andy mentioned in this answer ) can help you protect the target branches - those the pull requests address as To branch, but the From (source) branch can be any, and it is not enforced.

If you are ready to write some code to support this scenario, here is the proposed approach:

Configure TFS/VSTS to run Azure Functions as a branching policy . Your function can be as simple as checking the source branch and set the pull request status to Failure in case the branch is not in the list of expected source branches. Otherwise, set the PR status to Success .

One more useful link: Configure a branch policy for an external service . You can configure it as a required policy, thus it won't be possible to complete the PR until it is satisfied.

You can access a feature called Branch Policies to enforce pull requests from the specific branches.

After you set up a branch policy, you cannot directly push changes to the branch. Changes to the branch are only made through pull requests.

In you scenario you just need to Configure branch policies for develop and hotfix branches.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM