CI vs CD: What is CI?
Continuous Integration: frequently integrating changes into main with automated validation (build, unit tests, lint/static checks). Goal: main stays in a deployable state.
CI vs CD: What is CD (Delivery)?
Continuous Delivery: every change passes the pipeline and is ready to deploy; production deploy may require manual approval.
CI vs CD: What is Continuous Deployment?
A form of CD where every change that passes the pipeline is automatically deployed to production (less common in many orgs).
Why do teams use CI/CD pipelines?
To automate quality checks, reduce human error, speed up delivery, ensure consistency/repeatability, and make deployments safer.
Pipeline mental model
A production line: checkout → build → test → quality gates → package → publish artifact → deploy (dev/staging/prod) → post-deploy checks/monitoring.
What is a pipeline stage?
A logical step in the automated workflow (e.g., build, unit tests, integration tests). Stages help isolate failures and enforce gates.
Typical CI stage: Checkout
Pull the correct version of source code from the repository to the runner/agent so the build can run reproducibly.
Typical CI stage: Build (Java)
Compile and package the app (e.g., mvn package / gradle build). Ensures code compiles and dependencies resolve.
Typical CI stage: Unit tests
Fast, isolated tests (no real DB/network). Provide quick feedback and catch logic regressions early.
Typical CI stage: Integration tests
Tests that run with real components (e.g., DB in container, Spring context). Catch wiring/config/contract issues.
What is a quality gate?
Automated checks that must pass before merging/deploying (lint, static analysis, coverage thresholds, security scans).
What is an artifact in CI/CD?
The immutable build output (e.g., JAR, Docker image). Best practice: build once, deploy the same artifact across environments.
Why ‘build once, deploy same artifact’?
Prevents environment-specific differences, improves reproducibility, and makes debugging/rollbacks safer because you know exactly what ran in each env.
What is promotion (artifact promotion)?
Moving the same artifact through environments (dev → staging → prod) after it passes validations in each stage.
Why do we have environments (dev/staging/prod)?
Dev for rapid iteration, staging to validate in prod-like conditions, prod for real users. Separates risk and allows progressive validation.
What should usually run in CI?
Build, unit tests, fast static checks, quick security scans. The goal is fast feedback on every PR/commit.
What should usually run in CD?
Packaging/publishing artifacts, deployments to environments, smoke tests, post-deploy checks, approvals for prod.
What is a smoke test?
A small set of fast tests that verify the deployed service is basically working (health endpoint, a key API call, DB connectivity).
What is a rollback?
Returning to a known-good version after a bad deployment, often by redeploying the previous artifact.
Simple rollback strategy
Redeploy the last known-good artifact/version. Works well when artifacts are versioned and deployments are automated.
Blue/Green deployment
Maintain two environments (blue and green). Deploy to inactive one, switch traffic when healthy. Rollback = switch traffic back.
Canary deployment
Deploy to a small percentage of users/traffic first. Monitor metrics. If healthy, ramp up; if not, stop/rollback.
Feature flags: why useful?
Ship code disabled, enable gradually. Reduces risk, allows quick disable without redeploy, supports experiments.
What is a runner/agent?
The machine/container that executes pipeline jobs (Jenkins agent/node or GitHub Actions runner).