简体   繁体   中英

How do I achieve/setup GitFlow in AzureDevOps repos with PR branch policies on master and develop?

How can I achieve Git Flow on my Azure Repos when I have pull request branch policies on master and develop branch? I'd love to get it working but I don't know the best practice. I currently have gitflow etup on my Azure Git repo but I have PR branch policies on master. How can I finish releases or hotfix branches if the push to master will fail because there is no PR created. Similiarly, if I have PR branch policy in AzureDevOps repo for my develop branch, I cannot "finish" my feature using "git flow feature ...finish" because the push to develop branch will fail

I've tried it without PR branch policies on develop (for finishing features) and master (for release merge and /or hotfix merge)

I've tried to consult the branch strategy guide for AzureDevOps but it makes no mention of GitFlow https://docs.microsoft.com/en-us/azure/devops/repos/git/git-branching-guidance?view=azure-devops#manage-releases

The guidance is more directed at creating feature branches from "master" for new features and merging back with PR and then for releases it suggests your create release and hotfix branches from master that are never merged back.

Expected: be able to finish features and merge back to develop via PR be able to finish releas and hotfix and merge back to master and develop via PR at the same time.

Actual: Finishing a feature. release or hotfix fails when attempting to merge to any branches that have PR branch policy on them (master, develop)

In our standards meeting at my organization, your question came up just the other day. After looking into it for a few hours, my best answer is that GitFlow is not going to be compatible with all the extras Azure DevOps provides with git repositories. After all, GitFlow is simply a set of standards and workflows for managing branches in a git repository. Azure DevOps is a specific implementation of git repositories with a bunch of extras layered on top. For instance, if you've applied branch policies to develop, then GitFlow Feature workflows will not allow you to complete a feature branch off of develop because the commit cannot be made, as you have discussed in your question. Additionally, you'll find that build and release pipelines are wired up to watch specific branches, which would not work well with GitFlow's release workflow.

You will need to do the same thing I am doing now - decide what standards, processes, and workflows work best for your team given the technologies on which you're reliant (eg, Azure DevOps). To use GitFlow, you may have to create some funky standards for your group. For instance, you could create a Staging branch that all features are branched from. Then, you merge from Staging to Develop as needed with Pull Requests. At a certain point, however, I think you'll find that the things you have to do to make GitFlow work with the extras in Azure DevOps will cause more headaches and technical debt than just creating your own standards and processes.

A gitflow finish feature mergers the feature branch into the develop branch. So rather than using gitflow finish feature, we create a pull request to get the change into develop.

Finishing a release or hotfix can be a bit more tricky. To do this we created a step as part of the automated release definition (in Azure devops) that mergers the release branch into master and develop automatically. The users that runs this job (could be some build/release agent user) is exempt from the branch policies. There are still some cases when some manual intervention will be needed. ie when a commit to a release branch conflicts with a commit to the develop branch.

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