What is DevOps Branching Strategies
Wael Al-Wirr
Architecture | APIs | Data | Cloud | Security | xOps | Banking | Capital Markets | Manufacturing
Like tabs versus spaces, branching strategies is one of those emotive topics that trigger heated debates both online and offline. While many hold strong opinions on the best approach, as with many things in software development, the right answer depends on context. With that in mind, let’s look at what branching strategies are and how they tie into CI/CD.
Put simply, a branching strategy is your team’s agreement on how and when to create and merge branches in?version control. How you set up your version control system and use branches will impact how you set up your CI/CD pipeline, so it’s important to choose a model that meets your needs.
What is a branching strategy?
Your code branching strategy determines how and when developers branch and merge. There are several models including mainline, trunk-based development, task/feature branching, and more. When deciding on a method it is important to evaluate what makes sense for your team and product. Most version control systems will let you adopt any of these strategies.
How developers branch code and where/when it gets merged in the CI/CD pipeline are closely related. Branching determines how developers work. CI/CD branches decide how code is built, tested, evaluated, and eventually released.
A basic workflow starts with code being checked out. When the work in the branch is committed, CI/CD processes are triggered. This can be done with a merge or pull request. Then the CI/CD pipeline kicks into high gear.
The goal of CI/CD is to continuously integrate changes to find errors earlier in the process (a.k.a. “shift left”). This increases a project’s velocity by avoiding late stage defects and delays. It creates an environment where code is always ready for a release. Set up your projects and teams for success, with the right CI/CD branching strategy.
Why you need a branching strategy in DevOps
A properly implemented branching strategy will be the key to creating an?efficient DevOps process. DevOps is focused on creating a fast, streamlined, and efficient workflow without compromising the quality of the end product.
A branching strategy helps define how the delivery team functions and how each feature, improvement, or bug fix is handled. It also reduces the complexity of the delivery pipeline by allowing developers to focus on developments and deployments only on the relevant branches—without affecting the entire product.
How to Set Up Your CI/CD Branching Strategy ?
A code branching strategy is the foundation for your team. Your CI/CD strategy determines what actions in a branch trigger a build, test, and/or code review. It also determines how code moves through the DevOps pipeline.
When figuring out your CI/CD strategy, review:
领英推荐
Branching Strategies Options
Release Branching Strategy
With release branching, all the code that is meant to be deployed together lives on the same branch. This makes it easy to do isolated testing of new behavior, separate from the rest of the codebase or other in-progress work.
When working at a custom software consulting company, release branching can also be useful because it clearly defines what’s live on Production. This approach helps clients understand when it’s ‘go time’ for new features because deployments are pre-planned and concrete.
Feature Branching Strategy
Feature branching is similar to release branching, except instead of organizing the branches around a release of several features, you create one branch for each individual feature. For example, imagine your team needs to implement the following feature: “As a user, I can log in to the website with my username and password.” Depending on team structure and workflow, that might encompass several tickets or tasks on your project board.
Story or Task Branching
Though feature branching is closer to ‘continuous’ than release branching, it still can lead to similar problems with long-running branches, since a feature might take a long time to code to completion. That also means it has similar potential for merge conflicts.
Trunk-Based Development
Finally, the strategy that is truest to the core purpose of CI/CD: trunk-based development. This is honestly the scariest thing I’ve ever written: with trunk-based development, everyone commits and pushes to the?main?branch (the core codebase! without any side branches!), and those commits are deployed automatically! So scary!
GitFlow vs GitHubFlow
There are basically two ways to manage the software projects in GIT are?Git flow?and?GitHub flow. These two flows can help you manage your project and optimize your entire workflow in the team.
We see less and less usage of workflows that involve developing directly from the trunk or master branch. This can be especially cumbersome to manage vs other methods that have seen great success in software development. As we move forward, those that are adopting more SaaS implementations of Git and integrate with tasking will likely move away from this method in favor of a branching model.
Managing retail digital technologies and digital transformation in the 3rd world. Talk to me about reaching previously unreachable low tech customers in Africa and Asia.
2 年I think the branching strategy depends on the team size. In previous companies it was completely fine to push to main branch if your team consists of 3 people that also clean up the mess if anything breaks immediately.
Product Manager at Tamatem ??
2 年Nice outlining & illustration Wael Al Wirr ????