What Is a CI/CD Pipeline? Explained with a Real Example

Ask five DevOps engineers what CI/CD means and you may get five slightly different answers, but they all describe the same idea. Every time someone changes the code, a machine checks it, builds it and moves it toward production, with no one copying files around by hand.

The short answer: CI (continuous integration) means every code change is automatically built and tested as soon as it is pushed. CD means the tested build is then delivered automatically, either to a release-ready state (continuous delivery) or all the way to production (continuous deployment). A CI/CD pipeline is the series of automated steps that does this.

Pipelines sit at the centre of most DevOps work, and they come up in almost every interview, so they are a core part of any DevOps training in Pune. This guide walks through one pipeline from start to finish, with a real config file you can copy.

Why teams bother with CI/CD

Picture a team of six developers who each work on their own copy of the code for two weeks, then try to merge everything the day before a release. The merge breaks, nobody knows whose change caused it, and the release slips. That painful day is what CI was invented to remove.

When everyone merges small changes several times a day and a pipeline tests each one, a broken change shows up within minutes, while the person who wrote it still remembers what they did. Fixing it takes ten minutes instead of a weekend.

CD solves the other half. If deploying means a senior engineer following a twenty-step document at midnight, releases become rare and scary. If deploying is one automated job that has run hundreds of times, releasing on a Tuesday afternoon becomes normal.

Continuous delivery vs continuous deployment

The two CDs differ in only one step. In continuous delivery, the pipeline prepares a build that could go live at any moment, but a person clicks Approve before production. In continuous deployment, there is no button: if every test passes, the change goes live on its own.

Most companies, especially banks, insurers and other regulated businesses, use continuous delivery with a manual approval for production. Continuous deployment is more common at product companies with strong automated tests and good monitoring. In an interview, being able to explain this difference clearly is worth more than naming tools.

The stages of a typical pipeline

Pipelines vary, but nearly all of them follow the same order. Each stage only runs if the one before it passed, so a failure stops bad code early.

1. Source

The pipeline starts when code is pushed to a Git repository or a pull request is opened. This is why Git for DevOps beginners is usually the first thing to learn: branches, pull requests and merges are what trigger everything else.

2. Build

The code is compiled or packaged. For a Java app that might be a Maven build producing a JAR file. For most modern services it also means building a Docker image, so the same package runs the same way on a laptop, a test server and production.

3. Test

Unit tests run first because they are fast. Then come linting, security scans of dependencies and the image, and sometimes integration tests that start a database or call other services. A good rule of thumb is that this stage should finish in under ten minutes, or developers stop waiting for it.

4. Store the artifact

The tested build is saved somewhere permanent and given a version, usually the Git commit ID. Docker images go to a registry such as Docker Hub, Amazon ECR or GitHub Container Registry. Later stages deploy this exact artifact rather than building again, so what you tested is what you ship.

5. Deploy

The artifact is deployed to a test or staging environment first, then to production. The deploy step might run kubectl or Helm against a Kubernetes cluster, run Ansible against servers, or update a cloud service. After deploying, a short smoke test checks that the app actually responds.

6. Monitor and roll back

A pipeline’s job does not quite end at deployment. Teams watch error rates and response times after each release, and keep a fast way to return to the previous version. A rollback that takes one command is a big part of what makes frequent releases safe.

A real example: a pipeline in GitHub Actions

Here is a small but complete CI pipeline for a Node.js app. It runs on every push and pull request to the main branch, installs dependencies, runs tests and, on main only, builds a Docker image. Save it as .github/workflows/ci.yml in any repository to try it.

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

jobs:
  build-and-test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20
      - run: npm ci
      - run: npm test
      - name: Build image
        if: github.ref == 'refs/heads/main'
        run: docker build -t myapp:${{ github.sha }} .

Notice the pieces: a trigger (on), a machine to run on (runs-on), and steps that run in order. The image is tagged with the commit ID, github.sha, so every image can be traced to the exact code it came from. Adding a push to a registry and a deploy job is the natural next step.

The same pipeline could be written as a Jenkinsfile, a GitLab CI file or an Azure Pipelines file. The syntax changes, but the stages do not. If you are deciding which tool to learn, our comparison of Jenkins vs GitHub Actions covers where each one is used.

Mistakes beginners make with pipelines

  • Putting passwords in the YAML file. Use the tool’s secret store instead, such as GitHub Actions secrets or Jenkins credentials.
  • Building again for each environment. Build once, store the artifact, and promote the same one through test, staging and production.
  • Ignoring slow or flaky tests. A pipeline that fails randomly teaches people to ignore red builds, which defeats the purpose.
  • No rollback plan. Know how you would return to the previous version before you need to.

How to practise CI/CD on your own

Take a small app you already have, or a simple sample app, and push it to GitHub. Add the workflow above and make it pass. Then deliberately break a test, push, and watch the pipeline go red. Fix it and watch it go green. That loop is the heart of the job.

Next, push the image to a registry and add a deploy step to a free or low-cost target, such as a small cloud VM or a local Kubernetes cluster built with kind or minikube. A working pipeline with a link to its runs is one of the strongest items you can show; see our list of DevOps projects for your resume for ideas that build on it.

Frequently asked questions

Is CI/CD a tool?

No. CI/CD is a practice. Tools such as Jenkins, GitHub Actions, GitLab CI and Azure Pipelines are what you use to build the pipeline that puts the practice into action.

Do I need to know coding to build a pipeline?

You need to read code comfortably and write scripts, but you do not need to be a software developer. Most pipeline work is YAML, shell commands and a little scripting in Bash or Python.

Which should I learn first, Docker or CI/CD?

Learn the basics of Git first, then build a simple CI pipeline that runs tests. Add Docker once the pipeline works, so you can see how images fit into the build and deploy stages.

How long does it take to learn CI/CD?

Building and understanding a basic pipeline takes a few days of focused practice if you already know Git. Getting comfortable with deployments, secrets and rollbacks takes a few weeks of regular hands-on work.

Facebook
Twitter
LinkedIn
Email
Picture of Wandex
Wandex

DevOps Expert

ENroll Now

Fill up the form and we will contact you 

Get Free Course Syllabus & Counseling

Takes only 10 seconds to fill out!