Skip to content
Tutorials Center
My learning

Topics

Lesson 33 of 50 ยท Quality, Testing and Delivery

Version Control, CI and Delivery Pipelines

Learn how branching strategies, trunk-based development and CI/CD pipeline stages fit together, with read-only Git and pipeline files plus runnable stand-ins.

A team of ten people changing the same code base needs two things: a history of every change that anyone can inspect and undo, and a routine that checks every change before it reaches users. The first is version control, almost always Git. The second is continuous integration and delivery (CI/CD), a pipeline that builds, tests and ships the code automatically.

This lesson explains the ideas at the level a software engineer needs: how teams choose a branching strategy, what the stages of a pipeline are, and what a release flow looks like. Git and pipeline servers cannot run on this site, so the real commands and configuration files are shown read-only, and the runnable examples are JavaScript stand-ins: a small model of how long changes wait before merging, and a miniature pipeline runner. For hands-on practice with the real tools, use the Git tutorial and the CI/CD with GitHub Actions track.

What version control gives a team

Version control records each change as a commit: who made it, when, what changed and why. From that history you get:

  • Undo and archaeology. You can restore any earlier state and ask "who changed this line, and in which change?"
  • Parallel work. People work on separate branches and later merge them.
  • Review. A branch or pull request becomes a unit that colleagues can inspect before it joins the main line.
  • Traceability. A commit message that mentions a ticket links the code to the requirement (see configuration and change management).

A typical day in a real repository looks like this. These commands are read-only here; run them in a real terminal.

Terminal
git switch -c fix-rounding        # start a short-lived branch
# ...edit files, run the tests...
git add -A
git commit -m "Round totals half-up, fixes #214"
git push -u origin fix-rounding   # share it; the pipeline starts
# a pull request is reviewed and merged on the hosting service
git switch main
git pull

Branching strategies

A branching strategy is the team's agreement about which branches exist, how long they live and how they merge. Three families cover most teams.

Feature branching. Each feature or fix gets its own branch off main and returns through a pull request. Simple and widely used. The danger is a branch that lives for weeks: the longer it lives, the more main moves underneath it, and the harder and riskier the merge becomes.

Git Flow. A heavier model with long-lived develop and main branches plus release and hotfix branches. It suits products with explicit versions and scheduled releases (installed software, mobile apps with store review). It costs more merging and slows feedback, so many web teams avoid it.

Trunk-based development. Everyone integrates into one main branch (the trunk) at least daily. Branches, if any, live for hours rather than days. Unfinished work is hidden behind feature flags (a configuration switch that turns code on or off at run time) instead of staying on a branch. This is the model most closely tied to continuous integration, and the one used by teams that deploy many times a day.

Three ways to branch

Feature branches One branch per change, merged by pull request.
Git Flow Develop, release and hotfix branches for versioned products.
Trunk-based Tiny branches, daily merges, flags hide unfinished work.

The shorter the branch lives, the cheaper the merge.

1 / 2

The Git track compares these in depth in Git branching strategies. The core trade-off is integration frequency. Merging often means small merges, early conflict detection and always-fresh feedback. Merging rarely means big, painful, surprising merges. The stand-in below models only that one effect: if each developer's change touches a few random files out of a shared pool, how likely is it that two long-lived branches collide?

JS Long branches collide more

Press Run (or Ctrl + Enter) to see the console output here.

No output.

The numbers come from a toy model, not from measurements of real teams, and an overlap on a file is not always a true conflict. The shape is the lesson: the overlap rises steeply with branch lifetime.

Continuous integration

Continuous integration (CI) means every change is merged into the shared branch frequently, and each merge automatically triggers a build and a test run. The point is fast feedback: if a change breaks something, the author finds out in minutes, while the change is still fresh in their head. A CI practice has simple rules:

  • Keep the main branch always buildable. A red build is fixed first, before new work.
  • Keep the build fast (ideally under ten minutes), or people will stop waiting for it.
  • Run the same checks on every change, whoever wrote it.

Continuous delivery and deployment

Two terms that are easy to mix up:

  • Continuous delivery. Every change that passes the pipeline is ready to release. A human decides when to press the button.
  • Continuous deployment. Every change that passes the pipeline is released to production automatically, with no manual step.

Both need strong automated tests and a way to undo a release, which the next lessons cover under deployment and maintenance.

The stages of a pipeline

A pipeline is an ordered set of automated stages. Each stage must pass before the next one starts, and cheap, fast checks come first so that failures appear early.

flowchart LR
    C["Commit<br/>or pull request"] --> B["Build"]
    B --> U["Unit tests<br/>and static analysis"]
    U --> I["Integration<br/>tests"]
    I --> P["Package<br/>artifact"]
    P --> S["Deploy to<br/>staging"]
    S --> A["Acceptance<br/>checks"]
    A --> R["Release to<br/>production"]

A typical delivery pipeline. A failure at any stage stops the line and notifies the author.

Two ideas make this reliable. First, build once, deploy many: the pipeline builds one artifact (an archive, a container image, a package) and promotes that exact artifact through staging and production, so what you tested is what you ship. Second, environments should match: the more staging differs from production, the less a green staging run proves.

Real pipelines are described in a configuration file that lives in the repository, so the pipeline itself is versioned and reviewed like code. This is a typical shape, shown read-only in the style of GitHub Actions; the exact keys depend on the tool you use.

YAML
name: ci
on:
  pull_request:
  push:
    branches: [main]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: npm ci
      - run: npm run lint
      - run: npm test
  package:
    needs: test
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: npm run build

The needs: line is what makes package wait for test. The pipeline anatomy lesson and first workflow explain every key.

A pipeline runner stand-in

Here is a small model of what a pipeline server does: run stages in order, stop at the first failure, and skip the rest. The stages are plain functions that return true or false. This is not a real CI server. It shows only the control flow.

JS A miniature pipeline runner

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Pipeline #2 never reaches package, so a broken change cannot become a release artifact. That "stop the line" behavior is the whole safety property of CI.

A release flow

Putting the pieces together, one release flow for a trunk-based team looks like this:

  1. A developer opens a small pull request from a short-lived branch.
  2. The pipeline builds and tests it; a colleague reviews it (working in a team).
  3. The pull request merges to main, and the pipeline runs again on the merged result.
  4. The artifact is deployed to staging, then promoted to production by a button (delivery) or automatically (deployment).
  5. Releases are tagged in Git with a version number so any release can be reproduced (see semantic versioning).

Releasing to production is a separate decision from merging code. Feature flags let code reach production switched off, and the team turns the feature on when it is ready. For safe ways to expose a release to users gradually, see deployment strategies.

The next stand-in is a small release gate that decides what happens to a merged change, using rules a team might agree on.

JS A release gate decision

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Common mistakes

  • Long-lived branches that are merged "when the feature is done". Merge small and often, and hide unfinished work behind a flag.
  • A slow or flaky pipeline that people learn to ignore. Fix or quarantine flaky tests; they teach the team that red does not matter.
  • Rebuilding for each environment. Build once and promote the same artifact.
  • Secrets in the repository. Keep keys in the pipeline's secret store, never in version control.
  • Skipping the pipeline "just this once". The one time you skip it is the time it would have caught the problem.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. What is the main benefit of trunk-based development?

    Short branches and daily merges mean small, early, cheap integrations. Feature flags hide unfinished work.
  2. 2. What is the difference between continuous delivery and continuous deployment?

    Both keep changes releasable. Deployment removes the manual release step.
  3. 3. Why does a pipeline order its stages with cheap, fast checks first?

    Fast feedback is the goal. A lint failure should stop the line before a 20-minute test stage starts.
  4. 4. What does 'build once, deploy many' mean?

    Promoting the same artifact means the thing you tested is exactly the thing you ship.
  5. 5. Which branching strategy is best known for long-lived develop and release branches?

    Git Flow uses develop, main, release and hotfix branches, which suits versioned releases but slows integration.

Summary

  • Version control gives history, parallel work, review and traceability; a branching strategy decides how long branches live and how they merge.
  • Trunk-based development keeps branches tiny and uses feature flags; Git Flow suits versioned products at a higher merging cost.
  • CI builds and tests every merge; continuous delivery keeps changes releasable, continuous deployment releases them automatically.
  • A pipeline is ordered stages that stop at the first failure; build once, promote the same artifact.
  • Pipeline and Git files are real tools and shown read-only here; the JavaScript examples are stand-ins for the control flow.

Next: Deployment, Maintenance and Software Evolution.