CI/CD for Absolute Beginners: What It Is and Why Environments Exist
A plain-English guide to CI/CD and deployment environments for anyone new to DevOps. Learn what dev, staging, and production are, how many you need, and why each one matters.
TL;DR: CI/CD is the automated assembly line that takes your code from “I just typed it” to “real users are using it” — without a human babysitting every step. And environments (dev, staging, production) are the separate “rooms” your code passes through so that bugs get caught somewhere safe before they ever reach a real customer.
You Just Joined DevOps. Let’s Start From Zero.
Imagine you write some code on your laptop. It works on your machine. Great. Now… how does it actually reach the millions of people who will use the app? Who tests it? What if it breaks? What if it breaks for real customers and someone loses money?
This is the exact problem CI/CD and environments solve. They are the two ideas you’ll hear on day one of any DevOps job, so let’s understand both — slowly, with no jargon left unexplained.
What is CI/CD?
CI/CD stands for Continuous Integration and Continuous Delivery (sometimes Continuous Deployment). Think of it as a robot assembly line for your code.
Continuous Integration (CI) is the first half. Every time a developer finishes a small piece of code and “pushes” it, the system automatically pulls everyone’s code together, builds the app, and runs tests — all by itself. The whole point is to catch problems early, while the change is still small and easy to fix. Developers merge their changes back to the main branch as often as possible, and those changes are validated by creating a build and running automated tests against it. This avoids the nightmare of everyone merging a month’s worth of code at once and spending days untangling conflicts.
Continuous Delivery / Deployment (CD) is the second half. Once the code passes all the tests, CD automatically packages it and moves it toward release. Continuous delivery stops short of automatic production deployment, while continuous deployment automatically releases the updates into the production environment. The only difference between the two is that last step: delivery keeps a human “approve” button before going live, while deployment skips even that.
Put simply: CI = build and test automatically. CD = ship automatically.
Why Does CI/CD Matter?
Before CI/CD, releasing software was a scary, manual, once-in-a-while event. Someone would stay up late, run commands by hand, and pray nothing broke. CI/CD replaces that fear with a calm, repeatable routine.
The real benefits:
- Bugs are caught in minutes, not weeks. Because tests run on every change, you find out immediately if you broke something.
- Releases become boring (in a good way). Small, frequent updates are far less risky than one giant update. If something does break, you only have a tiny change to roll back.
- Less human error. Automation makes the development process more efficient, and continuous deployment allows a developer’s change to go live within minutes of writing it.
Boring releases are the goal. A boring release means nothing exploded.
How It Works (The Pipeline)
A CI/CD pipeline is just the sequence of automated steps your code travels through. Each stage acts as a gate that vets a certain aspect of the code; problems uncovered in an early stage stop the code from progressing. If a step fails, the line stops and the team gets notified.
A typical pipeline looks like this:
Developer pushes code
|
v
[ BUILD ] -> compile / package the app
|
v
[ TEST ] -> run automated tests (unit, integration)
|
v
[ DEPLOY to DEV ] -> developers' sandbox
|
v
[ DEPLOY to STAGING ] -> mirror of production, final checks
|
v
[ DEPLOY to PRODUCTION ] -> real users! (often needs approval)
Notice the last three boxes. Those are environments — and they’re the part beginners find most confusing. So let’s break them down properly.
What is an “Environment”?
An environment is a complete, separate copy of where your app runs — its own servers, its own database, its own settings. Environments are isolated spaces that represent different stages of your app’s lifecycle, from writing code to serving real users.
Why separate copies? Because you never want to test risky new code in the same place real customers are working. You need a safe room to make mistakes in, and a protected room where mistakes aren’t allowed. Environments give you exactly that separation.
The classic musical analogy makes it click: development is practicing alone, staging is the full-band rehearsal, and production is the live concert with the audience watching.
How Many Environments Are There?
The honest answer: it depends on the team, but the industry-standard setup is three. Development, staging, and production are the default environments of medium and large applications, though some teams use four or more. Let’s go through each one and why it matters.
1. Development (DEV)
This is the playground. It’s where developers write, experiment, and break things freely. Only developers have access, changes are frequent and immediate, and the data used is simulated or fictional to avoid any impact on real information.
Why it matters: It’s the only place where breaking the app has zero consequences. No real users, no real data, no panic. Mistakes here are free.
2. Staging (also called Pre-Production)
This is the dress rehearsal. It is built to look exactly like production — same configurations, same setup. A staging environment is one that exactly resembles a production environment; its primary use is to test all the installation, configuration, and migration scripts and procedures before they’re applied to production.
Why it matters: This is where you catch the bugs that only show up in a realistic, production-like setup — the ones that hid during development. Your staging environment should mirror production as closely as possible — same database structure, APIs, configurations, and dependencies — to eliminate surprises during deployment. If something is going to break, you desperately want it to break here and not in front of customers.
3. Production (PROD)
This is the live concert. The real app, real users, real data, real money. Deploying to production is the most sensitive step, as any problems result in immediate user impact.
Why it matters: Everything you did in the earlier environments was to protect this one. Stability and security are top priorities here, since any errors can impact customers and damage business reputation. That’s why production deployments are watched carefully, often need a human approval, and use safety tricks like rolling changes out to a small percentage of users first (called canary releases) before going to everyone.
Optional Extras You’ll Eventually Hear About
Bigger or more careful teams add more rooms: QA/Test (a dedicated environment for the testing team), UAT (User Acceptance Testing, where business stakeholders sign off), and Disaster Recovery (a backup production ready to take over if the main one fails). Other common environments include Quality Control for acceptance testing, sandbox for experiments not intended for production, and Disaster Recovery as an immediate fallback. Don’t worry about memorizing these yet — just know dev, staging, prod first.
Hands-On: Your First Tiny Pipeline
Here’s the smallest real CI/CD pipeline using GitHub Actions (a popular, beginner-friendly tool). Save this as .github/workflows/ci.yml in a repo, and GitHub runs it automatically on every push.
name: My First Pipeline
on:
push:
branches: [ main ] # run whenever code is pushed to main
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- name: Get the code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: npm install
- name: Run tests
run: npm test # if tests fail, the pipeline stops here
That’s it. The moment you push code, a machine spins up, grabs your code, installs everything, and runs your tests — no human involved. That is Continuous Integration, working. Adding a deploy step afterward turns it into full CI/CD.
Common Pitfalls Beginners Hit
- Treating staging and production as the same thing. They’re not. Treating them as the same can lead to unnecessary chaos. Keep them separate and keep staging as close to prod as possible.
- “It worked on staging!” Differences between environments (called drift) cause this. The fix: use the same builds and tools like Terraform or Docker so every environment is identical.
- Skipping tests to “save time.” A pipeline with no tests is just an expensive way to ship bugs faster. The tests are the safety net.
- Putting passwords directly in code. Secrets (passwords, API keys) should be stored in your CI/CD tool’s secret manager, never written in the pipeline file.
- Deploying straight to production with no approval. Until you’re confident, always keep a human “go” button before the live environment.
When You Need All Three (and When You Don’t)
| Situation | Recommended Environments |
|---|---|
| Personal project / learning | Dev + Production (skip staging) |
| Small startup, few users | Dev + Staging + Production |
| Medium/large app with real customers | Dev + Staging + Production (+ QA/UAT) |
| Banking, healthcare, high-risk | All of the above + Disaster Recovery |
Some companies with fewer users don’t have staging environments at all — they deploy carefully to production and watch a tiny slice of traffic. Start simple. Add environments as the stakes get higher.
Key Takeaways
- CI = automatically build + test every code change so bugs are caught early.
- CD = automatically deliver/deploy that tested code toward real users.
- A pipeline is the chain of automated steps; if one step fails, the whole line stops.
- Environments are separate copies of your app that let you fail safely before going live.
- The standard three are Dev (playground), Staging (dress rehearsal), Production (live concert).
- Keep staging as close to production as possible to avoid nasty surprises.
- Start with the fewest environments you can, and add more as risk grows.
Further Reading
- GitLab — What is CI/CD?: https://about.gitlab.com/topics/ci-cd/
- AWS — CI/CD on AWS: https://docs.aws.amazon.com/whitepapers/latest/cicd_for_5g_networks_on_aws/cicd-on-aws.html
- Wikipedia — Deployment environment: https://en.wikipedia.org/wiki/Deployment_environment
- GitHub Actions — Quickstart: https://docs.github.com/en/actions/quickstart