RousselTMLEARNING

Article · DevOps: From Discovery to Expertise

CI/CD (1/5): principles and anatomy of a pipeline

1. CI, CD and CD #

Three practices, often confused.

Definitions #

CI, continuous delivery, continuous deployment
The difference between continuous delivery and continuous deployment is the automatic release to production.
PracticeDefinitionCondition
Continuous integration (CI)every change is integrated into the main branch, built and tested automatically, several times a dayfast automated tests, short-lived branches
Continuous Deliveryevery version that passes the pipeline is deployable to production at any time, in one clickautomated, reproducible deployment
Continuous Deploymentevery version that passes the pipeline goes to production automaticallyfull confidence in the tests, progressive deployments, automatic rollback

CI answers « does my code integrate with everyone else's? », continuous delivery « can I ship now? », continuous deployment removes the question.

Why it pays off #

  • Smaller batches: each deployment changes little, so it breaks little and is diagnosed quickly.
  • Fast feedback: a developer learns within minutes that they broke something, not weeks later.
  • A reproducible process: releasing to production becomes a non-event.
  • Better DORA metrics: deployment frequency, lead time, change failure rate and time to restore.

2. Anatomy of a pipeline #

The stages from commit to production.

The stages #

Stages of a CI/CD pipeline
The first stages must be the fastest: fail early.
StageContentTarget duration
Commit stagecompilation, unit tests, lint, static analysis, secret detection< 10 min
Packagebuilding a single, versioned artifact (image, binary, package)a few minutes
Acceptance testsintegration and end-to-end tests on an ephemeral or staging environment< 30 min
Deploymentpromoting the same artifact to staging then productionminutes
Verificationsmoke tests, metric analysis, automatic rollback on degradationminutes

The technical building blocks #

NotionRole
Triggerpush, pull request, tag, schedule, manual trigger
Runner / agentmachine (often an ephemeral container) that runs the jobs
Job / stepunit of work; jobs in the same stage run in parallel
Cachedependencies reused from one build to the next to save time
Artifactoutput produced by a job and passed to the next ones or published
Environmentdeployment target (staging, production) with its secrets and approval rules
Secretscredentials injected at run time, never written into the repository

3. Fundamental principles #

What makes a pipeline reliable.

Build once, deploy many #

The artifact is built only once, given an immutable version (the commit SHA), and it is that same artifact that is tested and then promoted from staging to production. Rebuilding for production means deploying something that has never been tested.

Common mistake: An image tagged latest or rebuilt per environment breaks traceability: there is no way to know exactly what is running in production or to go back to the previous version.

The other rules #

  1. Pipeline as code: the pipeline definition is versioned with the code (.github/workflows, .gitlab-ci.yml, Jenkinsfile).
  2. Fail fast: quick checks first, the longest ones afterwards.
  3. A red pipeline takes priority: fix it (or revert the commit) before going further.
  4. External configuration: the artifact is identical everywhere, only the configuration changes (variables, secrets, 12 factors).
  5. Reproducibility: pinned tool and dependency versions, ephemeral runners.
  6. Everything goes through the pipeline, including urgent fixes: otherwise the pipeline stops being the source of truth.

4. A first pipeline #

The same logic with two tools.

GitHub Actions #

# .github/workflows/ci.yml
name: ci
on:
  push: { branches: [main] }
  pull_request: {}
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with: { python-version: "3.12", cache: pip }
      - run: pip install -r requirements.txt
      - run: pytest -q
  build:
    needs: test
    if: github.ref == 'refs/heads/main'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: docker build -t app:${{ github.sha }} .

GitLab CI #

# .gitlab-ci.yml
stages: [test, build]
test:
  stage: test
  image: python:3.12
  script:
    - pip install -r requirements.txt
    - pytest -q
build:
  stage: build
  image: docker:27
  services: [docker:27-dind]
  rules: [{ if: '$CI_COMMIT_BRANCH == "main"' }]
  script:
    - docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA .
Rest of the chapter: The next four lessons detail each part: continuous integration and testing, artifacts and environments, deployment strategies, then tools.

📄 End-to-end CI/CD (1/5): principles and anatomy of a pipeline →

My progress

  • ⏱ Estimated time : ≈ 8 min

Sign in to track your progress and take notes. Sign in

💬 Questions about this lesson

No questions yet: be the first to ask for help or share your configuration.

Ask a question about this lesson →

Recommended Articles

Terraform: principles, architecture and workflow

Understand Terraform: declarative infrastructure as code, architecture (core, providers, state), ...

Infrastructure as Code and GitOps: Terraform, Ansible and Argo CD

Manage infrastructure as code: declarative or imperative, Terraform (providers, state, plan, modu...

Platform engineering, FinOps and AI: the new frontiers of DevOps

Understand how DevOps is evolving: platform engineering and internal developer platforms (IDP), g...

k6 in continuous integration and on Kubernetes (k6-operator)

Automate performance tests: k6 in GitHub Actions and GitLab CI with blocking thresholds, distribu...

DevOps variants: understanding how engineering culture has evolved

Discover the different flavors of DevOps: DevSecOps, AIOps, NoOps, GitOps and FinOps. Understand ...

Organizing DevOps: value streams, teams and a blameless culture

Set up a DevOps organization: value chain and value stream mapping, Team Topologies, « you build ...

The wall of confusion

The 'wall of confusion' is a metaphor often used in a DevOps context to describe the cultural, or...

The CALMS framework: the 5 pillars of DevOps

Discover the CALMS framework, the essential foundation for a successful DevOps transformation, th...

Chaos engineering: principles, tools and practice with SLOs

A complete guide to chaos engineering: principles, steady state and hypothesis, blast radius, lin...

Support us

♥ SUPPORT US

Support RousselTM Learning

Courses, articles, labs and certificates stay free with no intrusive ads. A voluntary contribution, of any amount you choose, pays for hosting, lab environments and new content.

Contribute with PayPal Any amount · card or PayPal accountLearn more
QR code PayPal
Or scan this QR code with your phone

Thank you, every contribution counts!