Ravindra BagaleCourses & study guides मराठी

DevOps

Chapter 8: CI/CD Concepts

Friends, today we learn the CI/CD factory conveyor. When code is pushed the belt runs: lint → test → build → push → deploy. Artifacts, versioning, dev/staging/prod, fail fast, quality gates, and a prod safety habit. Do not fear.

What you will learn in this chapter

  • Pipeline stages from lint to deploy
  • Artifacts and versioning
  • Dev, staging and production environments
  • Fail fast and quality gates
  • When to use manual prod approval
  • CI/CD is the practice; Jenkins, GitHub Actions and GitLab CI are tools

Concepts in this chapter

  1. 8.0A Netflix-style release — CI/CD is the practice, Jenkins is a tool
  2. 8.1Why a pipeline — stop the ship on a failed check
  3. 8.2Pipeline stages — lint → test → build → push → deploy
  4. 8.3Artifacts and versioning
  5. 8.4Environments — dev, staging, production
  6. 8.5Fail fast and quality gates
  7. 8.6Manual approval for production — when and why
  8. 8.7CI vs CD vs deploy vs release (refresh)
  9. 8.8What a junior watches on a red pipeline
  10. 8.9Anti-patterns (spot them early)
  11. 8.10Versioning and release notes (lightweight)
  12. 8.11Lab — design badge API pipeline on paper

Review and practice

  1. ★8.8b Metrics of a healthy pipeline (plain English)
  2. ★8.8c Who owns a red build?

The chapter recap is at the end of the last concept page.

Practice Tasks

About this scenario

Suppose we are on the DevOps team at Zalando, the fashion e-commerce company, working from Berlin. Anna Schmidt leads the team, and we look after the size advice service. Costs are counted in EUR. In the tasks below we do real DevOps jobs on this project using what this lesson teaches. Zalando is a real company, but this project, the people, servers, IP addresses and numbers are made up for practice.

0 / 12

Easy GitHub Actions: test on every push

Why: Running tests on every push catches bugs before they reach main.

What to do: Write .github/workflows/ci.yml named CI that runs on push. One job test on ubuntu-latest with steps: actions/checkout@v4, actions/setup-node@v4 with node-version 20, run npm ci, run npm test.

How:
  1. Start from the top-level keys the task names.
  2. Indent child keys with 2 spaces (no tabs).
  3. Use "- " for list items and fill each value from the task.
  4. Check the colons and spacing, then click Check answer.

Easy Name the practice

Why: Knowing the names helps you in interviews and design talks.

What to do: At Zalando every developer merges small changes into main several times a day, and each merge is built and tested automatically. What is this practice called (two-letter short form)?

How:
  1. Write down the facts or numbers the task gives you.
  2. Work it out step by step.
  3. Type only the final answer (one word or number) in the box.
  4. Click Check answer.

Medium Deploy only after tests pass

Why: needs makes the deploy job wait for, and depend on, the test job.

What to do: Workflow on push with two jobs on ubuntu-latest: test (run: npm test) and deploy (run: ./deploy.sh eu-central-1) that needs test.

How:
  1. Start from the top-level keys the task names.
  2. Indent child keys with 2 spaces (no tabs).
  3. Use "- " for list items and fill each value from the task.
  4. Check the colons and spacing, then click Check answer.

Medium Deploy only from main

Why: Feature branches are built and tested but never deployed.

What to do: Declarative pipeline, agent any, stage Deploy with when { branch 'main' } and steps sh './deploy.sh eu-central-1'.

How:
  1. Start with pipeline { and close it with } at the end.
  2. Add agent, then stages { } with one stage('Name') { steps { } } per step.
  3. Put the commands inside steps using sh '...'.
  4. Count your { and } so every block is closed, then click Check answer.

Medium Delivery or deployment?

Why: The two words mean different levels of automation.

What to do: At Zalando every change that passes tests goes to production automatically, with no human approval. Is this continuous delivery or continuous deployment? Type one word.

How:
  1. Write down the facts or numbers the task gives you.
  2. Work it out step by step.
  3. Type only the final answer (one word or number) in the box.
  4. Click Check answer.

Medium Run only for main and pull requests

Why: Limiting triggers saves CI minutes and noise.

What to do: Write a workflow named Build whose on: runs for push to branch main and for pull_request to branch main. One job build on ubuntu-latest with a single step run: make build.

How:
  1. Start from the top-level keys the task names.
  2. Indent child keys with 2 spaces (no tabs).
  3. Use "- " for list items and fill each value from the task.
  4. Check the colons and spacing, then click Check answer.

Medium Nightly scheduled workflow

Why: Nightly runs catch slow-breaking things like expired certificates.

What to do: Workflow that runs on schedule with cron "0 1 * * *". Job scan on ubuntu-latest, step run: ./scan.sh.

How:
  1. Start from the top-level keys the task names.
  2. Indent child keys with 2 spaces (no tabs).
  3. Use "- " for list items and fill each value from the task.
  4. Check the colons and spacing, then click Check answer.

Hard Matrix build on three Python versions

Why: A matrix tests every supported version in parallel.

What to do: Write a workflow (on: push) with job test on ubuntu-latest using strategy.matrix.python with "3.10", "3.11", "3.12". Steps: actions/checkout@v4, actions/setup-python@v5 with python-version ${{ matrix.python }}, run pytest.

How:
  1. Start from the top-level keys the task names.
  2. Indent child keys with 2 spaces (no tabs).
  3. Use "- " for list items and fill each value from the task.
  4. Check the colons and spacing, then click Check answer.

Hard Manual approval before production

Why: A human sign-off stops an accidental production release.

What to do: Declarative pipeline, agent any, stage Prod with input message 'Deploy to production?' and steps sh './deploy.sh prod'.

How:
  1. Start with pipeline { and close it with } at the end.
  2. Add agent, then stages { } with one stage('Name') { steps { } } per step.
  3. Put the commands inside steps using sh '...'.
  4. Count your { and } so every block is closed, then click Check answer.

Hard Parallel test stages

Why: Running unit and lint at the same time halves feedback time.

What to do: Declarative pipeline, agent any, stage Checks containing parallel with stage Unit (sh 'npm test') and stage Lint (sh 'npm run lint').

How:
  1. Start with pipeline { and close it with } at the end.
  2. Add agent, then stages { } with one stage('Name') { steps { } } per step.
  3. Put the commands inside steps using sh '...'.
  4. Count your { and } so every block is closed, then click Check answer.

Hard Name the approach

Why: GitOps tools like Argo CD are now common in K8s teams.

What to do: At Zalando a tool inside the cluster keeps pulling manifests from a Git repo and makes the cluster match it. What is this approach called (one word)?

How:
  1. Write down the facts or numbers the task gives you.
  2. Work it out step by step.
  3. Type only the final answer (one word or number) in the box.
  4. Click Check answer.

Hard Cache dependencies

Why: Caching npm downloads cuts minutes off every run.

What to do: In job build (ubuntu-latest, on push) add steps: actions/checkout@v4; actions/cache@v4 with path ~/.npm and key npm-${{ hashFiles('package-lock.json') }}; run npm ci.

How:
  1. Start from the top-level keys the task names.
  2. Indent child keys with 2 spaces (no tabs).
  3. Use "- " for list items and fill each value from the task.
  4. Check the colons and spacing, then click Check answer.

Ravi Sir's Cards: 31 revision, interview and comparison cards for this chapter · मराठी cards