简体   繁体   English

CICD的Git分支策略

[英]Git branching strategies for CICD

Just looking for thought on below branching strategies keeping CICD in mind. 只是在考虑以下分支策略时要牢记CICD。

  1. Master branch - 主分支-

    1.1 Development branch - Fork from master 1.1开发部门-大师级的分叉

      Team A branch - Fork from Development branch and merge to development branch after feature implementation for QA/Integration testing Team B branch - same as above 1.1.1 Release branch - Goes in PROD 

Once Team A and Team B branch merge and QA verification done, create release branch and have Final regression on it. 团队A和团队B分支合并并完成质量检查后,请创建发布分支并对其进行最终回归。 This release branch will go to Production. 此发行分支将进入生产。

Then merge Release to master branch. 然后将Release合并到master分支。

Intent - 目的-

  1. Master branch is stable and production running code is available in it. 主分支是稳定的,并且其中包含生产运行代码。

  2. Team branch can deployed on DEV environment and have required CICD configuration on server. Team分支可以部署在DEV环境上,并且在服务器上具有必需的CICD配置。

Any issue with this approach? 这种方法有什么问题吗?

That's not true CI (by CI I mean development strategy, not tooling) because you have team branches meaning the teams' work is not integrated until merged into master - there are always teams whose work is not visible to other teams and which doesn't see work from other teams (thus open to the rebase/merge hell ). 这不是真正的CI(用CI,我指的是开发策略,而不是工具),因为您有团队分支,这意味着团队的工作直到合并到master中才被整合-总是有其他团队看不到并且看不到他们的工作的团队。查看其他团队的工作(因此可以进行调整基准/合并地狱 )。

For true CI strategy all teams would work on master (if really pulling task branches they'd be merged back into master very fast, not more than a few days lifespan) - everybody is practically on the same page. 对于真正的CI战略的所有团队将在工作master (如果真的拉任务的分支,他们会被合并到主非常快,不超过几天的寿命更多) -每个人都几乎是在同一页上。

A CI tool (and maybe a CD tool in a staging environment) would keep an eye on master health. CI工具(可能在暂存环境中为CD工具)将密切关注master健康状况。

Whenever master is current release -ready or when changes for the next release start colliding with the current release (release divergence) the current_release branch is pulled and will never be merged back into master (such merges would be a big problem due to release divergence). 只要mastercurrent release就绪的,或者当下next release更改开始与current release发生冲突(发行分歧)时, current_release分支就会被拉出,并且永远不会合并回master(由于发行分歧,这种合并将是一个大问题) 。 Any bug fixes in current_release (if applicable to master as well) would be cherry-picked and double-committed (just because a fix is OK on one branch it doesn't mean it's OK on another branch). current_release任何错误修复(如果也适用于master )都将被精心挑选和两次提交(仅因为一个分支上的修复是确定的,并不意味着它在另一分支上是确定的)。

The current_release branch is practically your production branch. 实际上, current_release分支是您的生产分支。 It needs it's own CI/CD setup, tailored on the current release features. 它需要根据current release功能量身定制的CI / CD设置。 Production builds are just labels on this branch. 生产版本只是该分支上的标签。

The master branch continues to evolve towards next release . master分支将继续朝着next release发展。

Rinse and repeat. 冲洗并重复。

You can also have further sub-branches of current_release for multi-level releases (major/minor/etc), which are also never merged back into their parent branch. 您还可以为多层发行版(major / minor / etc)提供current_release其他子分支,这些子分支也永远不会合并回其父分支。 The relationship between each such sub-branch and its parent is exactly as the relationship between current_release and master . 每个此类子分支与其父级之间的关系与current_releasemaster之间的关系完全相同。

To truly being doing CI (and CI is required to do CD) you would merge to master very regularly and not have long lived feature branches. 要真正地执行CI(并且需要CD才能执行CI),您将非常有规律地合并以掌握母带,并且没有很长的功能分支。 I believe that once a day is expected for it to be "CI". 我相信,每天将其设置为“ CI”。

An alternative approach to the one you suggest is to have short lived developer branches for daily work. 您建议的一种替代方法是让短暂的开发人员分支从事日常工作。 Then to have a deployment pipeline that moves each code change through a series of test stages. 然后要有一个部署管道,通过一系列测试阶段来移动每个代码更改。 Only once the changes have passed each stage will they go to the next stage and be ready for production. 只有在每个阶段都通过更改后,它们才能进入下一个阶段并准备投入生产。 This allows you to work on master but to remain stable and only allow passing code to enter production. 这使您可以在主服务器上工作,但保持稳定,并且只允许传递代码进入生产环境。

To deal with independent feature work you can use feature toggles instead of branches. 要处理独立的要素工作,可以使用要素切换而不是分支。 You can toggle features on and push to master to test them and deploy if all is well. 如果一切正常,您可以打开功能并按下以测试它们并进行部署。 If not, or if there is a business need to remove a feature, you can toggle off the feature and continue to use master safely. 如果不是这样,或者如果业务需要删除某个功能,则可以关闭该功能并继续安全使用master。 I have seen this work very well on two products I have worked on. 我已经在使用的两个产品上看到了很好的效果。

I know this is very simplified but it is just to make a suggestion of alternatives for you and hopefully to help. 我知道这非常简化,但这只是为您提出替代建议,希望对您有所帮助。 You can learn more about implementing these techniques on a bunch of blogs and stackoverflow answers - http://martinfowler.com/articles/feature-toggles - http://www.paulhammond.org/2010/06/trunk/alwaysshiptrunk.pdf - Feature Toggles vs Feature Branches 您可以了解更多有关在大量博客上实现这些技术以及stackoverflow答案的信息-http: //martinfowler.com/articles/feature-toggles-http : //www.paulhammond.org/2010/06/trunk/alwaysshiptrunk.pdf - 功能切换与功能分支

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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