Lesson 01 beginner

Introduction to CI/CD

What continuous integration, continuous delivery and continuous deployment really mean, the problems they fix, how a pipeline is put together, the words you will see every day and how GitLab CI/CD compares with GitHub Actions, Jenkins and Argo CD.

CI/CD is the habit of letting a machine build, check and release your code every time someone changes it. Instead of a person running tests “when there is time” and copying files to a server on Friday evening, every push starts an automated pipeline that answers two questions within minutes: did this change break anything? and can it go to users?

The letters hide three related practices, and mixing them up is the most common source of confusion:

  • CI, continuous integration: merge small changes often and check each one automatically.
  • CD, continuous delivery: keep the code ready to release at any moment; a person picks the moment.
  • CD, continuous deployment: every change that passes the checks goes to production on its own.

Life before CI/CD

Picture the Orbit team before they automated anything. Four developers, one API, one web front end, one production server.

Merge day

Each developer worked on a long-lived branch for two or three weeks. On merge day the branches finally met, and the problems they had been hiding all surfaced at once:

  • Two features changed the same function in incompatible ways.
  • Tests passed on every branch alone and failed on the combined code.
  • Nobody could tell which of 60 commits broke the login page.

Teams used to call this integration hell. The pain was not the merging itself, it was discovering problems weeks after they were written, when nobody remembered the details.

The deploy checklist

Releasing meant following a wiki page: build on your laptop, copy the archive with scp, stop the service, unpack, run migrations, start the service, check the logs. It went wrong in predictable ways:

  • A step got skipped at 7 p.m. on a Friday, usually the migration.
  • “Works on my machine”: the build used whatever Node.js version the person’s laptop had.
  • Rollback was a guess: which archive was running before?
  • No audit trail: nobody could say who deployed what, or when.

Late bugs cost more

A bug found ten minutes after it was written is a two-line fix: the author still has the code in their head. The same bug found by a customer three weeks later needs a support ticket, an investigation, a hotfix branch and an emergency release. The whole point of CI/CD is to move the moment of discovery as close to the moment of writing as possible.

Continuous integration

With CI, everybody merges small changes into the main branch often, at least daily, and a server checks every change the same way:

  1. Fetch the exact commit that was pushed.
  2. Install dependencies from the lock file.
  3. Build the application.
  4. Run linters and unit tests.
  5. Report green or red back on the commit and the merge request.

Small, frequent merges mean conflicts are small too, and when something breaks the culprit is one of a handful of commits, not sixty. The rule that makes CI work is social, not technical: a red main branch is everyone’s top priority.

CI is a practice, not a server. Running a pipeline on a branch nobody merges for a month is not continuous integration. The “continuous” part is merging often.

Continuous delivery

Continuous delivery adds one promise on top of CI: the main branch is always releasable. Every passing change is built into a versioned package (a container image, an archive, an app bundle), deployed to a staging environment automatically and waiting for one click to go to production.

The release itself stays a human decision. Good reasons to keep that button:

  • The business wants features out on a specific date, with a marketing launch.
  • Regulations ask for a named approver for each production change.
  • Another team, an app store review or a database migration needs coordination.

The key difference from the old world: pressing the button is boring. The same steps run every time, so releasing on a Tuesday afternoon is as safe as it will ever be.

Continuous deployment

Continuous deployment removes the button. If a change passes every automated check, it goes live, often dozens of times a day. That only works when the team can trust its safety net:

  • tests that catch real regressions, not just a coverage number;
  • monitoring and alerts that show a bad release within minutes;
  • gradual rollouts (canary, blue-green, feature flags) that limit the damage;
  • a rollback that is one command and has been practised.

Most teams walk the path in order: CI first, then continuous delivery, and continuous deployment only for the services where the safety net is mature. Plenty of excellent teams stop at continuous delivery and never look back.

The three practices side by side

Continuous integrationContinuous deliveryContinuous deployment
Question it answersDoes this change fit with everyone else’s?Could we release right now?Should this change go live by itself?
What runs automaticallyBuild, lint, testsEverything in CI, plus packaging and a staging deployEverything, including production
Human stepFix a red pipelineApprove the production releaseNone before production
Orbit exampleA push to a branch runs the API testsA merge to main deploys staging; a button deploys productionA merge to main is in production 15 minutes later

What a pipeline is made of

A pipeline is the automated path a commit walks through on its way to production. In GitLab it is described in one file at the root of the repository, .gitlab-ci.yml, and drawn as columns from left to right:

 commit ──▶ [ build ] ──▶ [ test ]       ──▶ [ deploy ]
             compile       unit-tests        staging
                           lint              production (manual)

Here is a peek at the file behind that picture. You will write it yourself in lesson 2, so do not worry about the details yet:

stages: [build, test, deploy]

build-api:
  stage: build
  script: npm ci && npm run build

unit-tests:
  stage: test
  script: npm test

deploy-staging:
  stage: deploy
  script: ./scripts/deploy.sh staging

Three ideas carry most of the weight:

  • Stages are the columns. They run in order, and a stage only starts when the previous one succeeded.
  • Jobs are the boxes. Each job runs a list of shell commands in a clean environment. Jobs in the same stage run in parallel.
  • Triggers are what starts the pipeline: a push, a merge request, a tag, a schedule, a click on “Run pipeline” or an API call.

The vocabulary you will use every day

TermMeaningOrbit example
PipelineOne run of all the jobs for one eventPipeline #1842 for commit a1b2c3d
StageA group of jobs that runs at the same point in the ordertest
JobOne unit of work: an image and a scriptunit-tests runs npm test
RunnerThe machine or container that executes jobsA GitLab hosted Linux runner
ArtifactA file a job saves for later jobs or for people to downloadThe dist/ folder, a test report
CacheFiles kept between pipelines to save timenode_modules downloads
TriggerThe event that started the pipelineA merge request was opened
EnvironmentA place the code is deployed tostaging, production

The feedback loop

The simplest way to think about CI/CD is a loop: commit, pipeline, feedback, repeat. A developer pushes, the pipeline runs, and within minutes the result shows up on the merge request. Green means move on. Red means fix it now, while the change is small and fresh.

Everything you will learn in this course, from caching to parallel tests to rules that skip useless jobs, exists to make that loop shorter and more trustworthy. A ten-minute loop gets used. A forty-minute loop gets ignored, and people start merging without waiting.

What CI/CD gives you

  • Smaller, faster releases. Shipping becomes routine instead of an event.
  • Fewer bugs in production. Every change runs the same checks; nothing depends on someone remembering.
  • Confidence. Developers refactor without fear because the tests will tell them.
  • Identical environments. Builds run in pinned container images, not on someone’s laptop.
  • An audit trail. Every deploy has a pipeline, a commit, an author and a timestamp.
  • Living documentation. .gitlab-ci.yml is the release process, reviewed like any other code.

One change, start to finish

A customer reports that Orbit drops the last word of long notes. A developer fixes it on a branch called fix-note-truncation and opens a merge request:

  1. The push starts a pipeline. build compiles the API and the front end.
  2. test runs unit tests, an API contract test and the linter in parallel. A new test reproduces the bug and now passes.
  3. A reviewer reads the diff, sees the green pipeline and merges.
  4. The merge to main starts another pipeline. It builds a container image tagged with the commit, pushes it to the registry and deploys staging automatically.
  5. The product owner checks the fix on staging and clicks deploy production. With continuous deployment, step 5 would happen by itself.

Nobody copied a file, guessed a version, skipped a test or wondered what was running in production.

The tools you will meet

ToolWhere it livesConfigurationStrengthTrade-off
GitLab CI/CDBuilt into GitLab.gitlab-ci.ymlRepo, merge requests, registry, environments and security scans in one placeTied to GitLab
GitHub ActionsBuilt into GitHub.github/workflows/*.ymlHuge marketplace of reusable actionsTied to GitHub
JenkinsYour own serverJenkinsfile (Groovy)Runs anywhere, endless pluginsYou maintain the server and the plugins
CircleCIHosted service.circleci/config.ymlFast setup, strong cachingOne more platform to pay for and secure
Argo CDInside KubernetesGit repo of manifestsGitOps deploys that keep clusters in syncDeploys only; you still need CI for builds and tests

This course uses GitLab CI/CD because everything you need lives in one product: the repository, the merge request, the pipeline, the container registry, the environments page and the security reports. GitLab.com gives Free accounts hosted runners and a monthly allowance of compute minutes, so you can start without a server. The Terraform Tutorial already shows a GitHub Actions pipeline, and you will notice the same ideas in both.

Myths worth dropping now

  • “CI/CD is for big companies.” A solo developer gets value from tests on every push on day one.
  • “CD means production deploys without a human.” That is continuous deployment. Continuous delivery keeps the button.
  • “A pipeline is just the test suite.” It also builds, packages, scans, versions and deploys.
  • “We will add CI later.” Later never gets easier. A five-line pipeline today is better than a perfect one next quarter.

Exercise

Orbit merges to main, the pipeline builds and tests the change, deploys it to staging and then waits for the product owner to click “deploy production”. Which practice is this?

  1. Continuous integration only
  2. Continuous delivery
  3. Continuous deployment
  4. Manual deployment
Show answer

Answer: B. The code is always releasable and staging is automatic, but a person chooses when production happens. Without that final button it would be continuous deployment.

Exercise

In a GitLab pipeline, how do stages and jobs relate?

  1. A job contains several stages that run in order
  2. A stage is a step in the order, like build or test, and holds one or more jobs that do the actual work
  3. Stages and jobs are two names for the same thing
  4. Each stage runs on its own server and jobs are optional
Show answer

Answer: B. Stages set the order (build before test before deploy). Jobs are the units that run commands. Jobs in the same stage run in parallel.

Exercise

Why does continuous integration insist on merging small changes often?

  1. Because GitLab charges less for small commits
  2. Because long branches cannot be tested
  3. Because conflicts stay small and a failure points to a handful of recent commits
  4. Because it removes the need for code review
Show answer

Answer: C. The longer branches live apart, the bigger the surprise when they meet. Frequent merges keep every problem small and easy to trace.

Key takeaways

  • CI checks every change automatically; continuous delivery keeps main releasable; continuous deployment ships every passing change.
  • A pipeline is stages in order, jobs in parallel inside each stage, started by a trigger.
  • Runners execute jobs, artifacts pass files along, environments are where code lands.
  • The goal is a short, trustworthy feedback loop: commit, pipeline, feedback.
  • GitLab CI/CD keeps the repo, pipeline, registry and environments in one product.

FAQ

What is the difference between CI, continuous delivery and continuous deployment?

CI builds and tests every change. Continuous delivery also packages and stages every change so it can be released at any time, with a person choosing when. Continuous deployment releases every passing change automatically. When someone says “CD”, ask which one they mean.

Is CI/CD worth it for a small or personal project?

Yes, at least the CI part. Tests and a build on every push take ten minutes to set up and catch mistakes before they reach anyone. Add automated deploys to a staging environment next, and production automation when you trust your tests.

How long should a pipeline take?

Aim for feedback in under ten minutes on a merge request. Past fifteen minutes people stop waiting and start merging blind. Lessons 3, 9 and 13 cover caching, parallel jobs and test splitting to stay fast.

What is the difference between a pipeline, a stage and a job?

A job is one task with a script. A stage is a group of jobs that run at the same point in the order. A pipeline is one complete run of all stages, started by one event such as a push.

Should I learn GitLab CI/CD or GitHub Actions first?

Learn whichever your team or your next job uses. The concepts in this course (stages, jobs, runners, artifacts, caching, environments, secrets) transfer almost one to one; only the YAML keywords change.

Does CI/CD mean every commit goes to production automatically?

No. That is continuous deployment, the last and optional step. Many mature teams keep a manual approval before production and still get most of the benefit.

↑ ↓ navigate Enter open Esc close