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

End-to-end CI/CD (2/5): continuous integration, testing and quality

Succeed with continuous integration: the test pyramid, unit, integration, contract and end-to-end...

End-to-end CI/CD (3/5): artifacts, registries and environments

Deliver continuously: immutable, versioned artifacts, image and package registries, promoting the...

End-to-end CI/CD (5/5): GitHub Actions, GitLab CI, Jenkins and Argo CD in practice

Compare and use CI/CD tools: GitHub Actions, GitLab CI, Jenkins, Argo CD and Flux; a complete pip...

End-to-end CI/CD (4/5): deployment strategies and rollback

Deploy without downtime and without risk: recreate, rolling update, blue/green, canary, feature f...

DevOps best practices: culture, CI/CD, infrastructure as code and measurement

DevOps best practices: culture and collaboration, continuous integration and delivery, trunk-base...

DevSecOps: securing the software supply chain end to end

Integrate security into the DevOps pipeline: shift-left, threat modeling, secret detection, SAST,...

Measuring DevOps performance: DORA metrics, SPACE and continuous improvement

Measure and improve delivery performance: the DORA metrics (deployment frequency, lead time, chan...

Observability, SRE and incident management for DevOps teams

Operate what you ship: metrics, logs and traces, golden signals, SLIs, SLOs and error budgets, ac...

Git for DevOps: branches, code reviews and versions

Organize work with Git in a DevOps approach: trunk-based development or GitFlow, short-lived bran...

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!