https://www.techtarget.com/whatis/definition/trunk-based-development
In software development, a trunk is the base code into which all subsequent code is merged. Copies made from the source code are known as branches, extending outward from the trunk.
Trunk-based development is a branching model whereby software designers regularly make small code changes to a single shared branch in the version control system. The shared branch, or trunk, is also called the baseline or mainline branch.
Software trunking should not be confused with trunking in networking. The latter term describes the infrastructure of a physical line or link that can carry many signals simultaneously for network access between two points.
Trunking helps a development team avoid lengthy code integration tasks and improve its efficiency. All changes are pushed directly to the trunk, even if not in final form. Errors are addressed quickly and remediated before they go live.
Project teams run automated unit tests before each commit, or change, to identify and resolve code conflicts. Pair programming teams, or a similar review process, ensure each line of work is scrutinized before moving to the trunk.
The trunking approach diverges from features-based branching methods in the following ways:
To understand the role of trunk-based development, it is useful to compare it to Agile software development methods, particularly open source Git. Both styles strive for continuous integration (CI) and continuous delivery, but they differ in how they work and the way they are used. A big difference is in the version control systems.
With trunking, features are made available sooner without wholesale rewrites, while preserving software build quality. The trunk code should be maintained in a production-ready state to support the following elements:
Git development is a features-based approach that the Gitflow workflow tool manages. Long-lived feature branches are widely deployed to maintain code changes. A developer creates a new feature branch off the trunk, works on it and then creates pull requests to get feedback from team members.
In Gitflow, each branch is assigned a role. There are rules governing how the branches interact. Gitflow offers more control over which features get merged than trunking. Gitflow is often associated with prepackaged software builds that users download.
Git integration is also weightier. Each branch is developed independently and isolated to ensure the original code remains stable. All changes are merged at the same time, increasing the risk of code conflicts.
The Gitflow repository uses two branches to track a project's history: a mainline branch and a develop branch:
The result of branching is a major release branch that incorporates all minor revisions in the trunk. The existing release branch is deleted and a new one is carved out of the code base. In trunking, one or two release engineers manage the cadence of a final release branch. In Git, Gitflow manages this process, merging only release branches and bug fixes in the trunk.
Reduced complexity is a major emphasis of trunk-based software design. With the trunk as a shared repository, software gets amended and shipped to production at an accelerated pace. Working in trunk positions enables a software team to certify that all major releases will happen without a problem. Teams achieve a higher level of performance because the product release cycle is predictable.
Although not suitable for every environment, using the trunk method helps development teams do the following:
Trunk-based development does have some drawbacks. The fast-paced environment is most often associated with larger organizations with senior DevOps engineers who work on tight timelines. These software designers need to be able to:
By contrast, developing in Git or another Agile-based framework is generally considered a more suitable implementation for organizations that:
The principle behind trunk-based development is to assimilate every change as soon as possible in version control. This keeps the continuous integration process moving along. But developers used to Agile-type branching must adopt a different mindset.
Industry best practices for trunk-based software include the following six steps:
Learn more about how trunk-based development compares to featured-based methodologies.
15 Sep 2021