Integrate early, integrate often. Build a shared codebase with confidence.
Continuous Integration is widely misunderstood. It's not just a build server. It's not just running tests on every commit. Those are tools that support CI—but CI itself is a practice.
Real CI means:
The "continuous" part is key. If you're integrating weekly, that's not continuous. If you have long-lived feature branches, that's not continuous. CI means integrating your work with everyone else's work every day, usually multiple times a day.
CI Is a Social Practice
CI is about how the team works together, not just about tooling. A Jenkins server that runs tests on month-old branches isn't CI.
True CI requires trunk-based development: everyone commits to the main branch (often called "trunk" or "main").
This sounds scary. Won't people break things? That's where the discipline comes in:
Long-lived branches are the enemy of CI. When you develop on a branch for weeks, you're not integrating. You're just postponing integration—and the longer you wait, the harder it gets.
Branch for hours, not days. Integrate daily, not weekly.
A developer creates a branch, works for 2-3 hours, runs all tests locally, then merges to main. This happens 3-4 times per day per developer. Integration is boring because conflicts are rare and small.
Developers create feature branches that live for 2-3 weeks. They merge to main when the feature is 'done.' Merge conflicts are painful. Integration bugs are common. The 'CI server' just tests the stale main branch.
For CI to work, the build and test cycle must be fast. Martin Fowler suggests the 10-minute rule: the entire build, including all tests, should complete in under 10 minutes.
Why 10 minutes? Because:
If your build takes too long:
Some teams run a fast subset locally (unit tests) and the full suite on the CI server. That's fine as long as the full suite runs quickly enough to provide timely feedback.
The build will break. What matters is what happens next.
The rule: When the build breaks, fixing it becomes the top priority. Everything else stops.
This might seem extreme, but consider: a broken build means the team can't trust the main branch. Everyone's work is blocked because they can't integrate safely. Every minute the build is broken is a minute of accumulated risk.
Who fixes it? Usually the person who broke it. But if they're stuck, others help. A broken build is a team problem, not an individual problem.
How to prevent breaks:
Some teams use a "CI sheriff" rotation—someone responsible for watching the build and coordinating fixes. This prevents the bystander effect where everyone assumes someone else will fix it.
Broken Builds Are Emergencies
A broken build that stays broken for hours is a team failure. Treat it with the same urgency as a production incident.
CI is the foundation for more advanced practices:
Continuous Delivery (CD): Every commit can be deployed to production. Deployment is a business decision, not a technical one.
Continuous Deployment: Every commit that passes tests is automatically deployed to production. No human approval required.
Not every team needs continuous deployment. But every team benefits from CI. Start there.
CI metrics to watch:
CI isn't just about catching bugs. It's about creating a rhythm where integration is boring, routine, and safe. When integration is safe, everything else gets easier.