DevOps, CI/CD and DevSecOps
Concise study notes on DevOps, CI/CD and DevSecOps: definitions, pipeline concepts, common tools and exam-style worked examples for engineering students.
Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.
Why it matters
DevOps, CI/CD and DevSecOps are used by engineers to deliver software faster, with fewer integration problems, and with security built into the process. In industry these practices reduce lead time for changes, increase deployment frequency and improve reliability of releases. Common metrics you should know: the four DORA metrics — deployment frequency, lead time for changes, change failure rate, and mean time to restore (MTTR).
Key ideas
Start from first principles and simple definitions. Bold each term when defined.
DevOps — a set of cultural practices and organisational processes that aim to shorten the system development lifecycle and provide continuous delivery with high software quality. Assumes close collaboration between development and operations teams, automation of the delivery pipeline, and feedback loops.
Continuous Integration (CI) — the practice of merging developer working copies to a shared mainline frequently (often many times per day) and automatically building and testing each merge. Precise definition: every commit to the shared branch triggers an automated build and test sequence; the sequence must halt and report if build or tests fail.
Continuous Delivery (CD) — the practice of ensuring code is always in a deployable state; after CI, CD automates further stages (integration tests, staging deployment, release artefact creation) so that deployment to production can be done on demand with minimal manual steps. Assumption: automated tests and deployment processes are sufficiently reliable that the software is always releasable; a manual approval gate before production may still be used as a business control.
Continuous Deployment — a stricter form of CD in which every change that passes automated tests is automatically deployed to production (no human gate). This requires mature test suites and reliable rollback.
DevSecOps — integrating security practices into DevOps: shift security-left by embedding automated security checks (static analysis/SAST, dependency scanning/SCA, secret detection, container image scanning, DAST, and IaC misconfiguration scanning) into CI/CD pipelines. Also generate a Software Bill of Materials (SBOM) and sign artefacts/provenance (e.g., Sigstore/cosign) to strengthen software supply-chain security. Assumption: security tools can be automated to provide fast feedback suitable for developer workflows.
Pipeline — an automated sequence of stages (build → test → package → scan → deploy) that run when triggered by events (commits, pull requests). Draw: a horizontal row of labeled rectangles: "Source" → "Build" → "Unit Test" → "Integration Test" → "Security Scan" → "Package/Publish" → "Deploy (staging)" → "Manual Approval?" → "Deploy (prod)". Label arrows with "automated" and event triggers (e.g., push, PR).
Build — compile and assemble source into binaries or packages. In interpreted languages build may mean dependency installation and bundling.
Unit test / Integration test / End-to-end (E2E) test — unit tests exercise single components; integration tests exercise interactions between components; E2E tests exercise the whole system from user perspective. Exams expect the differences and where to run each in pipeline.
Artifact repository — a place to store built artefacts (Docker registry, Maven/Nexus, npm registry). Important for traceability and immutable releases.
Immutable infrastructure — treat deployment units (VM images, containers) as immutable artefacts; changes are made by replacing units, not modifying them in place. This simplifies rollbacks and consistency. Common deployment strategies that pair with this are blue/green and canary releases, often combined with feature flags for progressive delivery.
Infrastructure as Code (IaC) — defining infrastructure (networks, VMs, storage) using declarative or imperative code (Terraform, CloudFormation, Ansible). Exact definition: infrastructure resources are declared in code and changes are applied through automated tools so they are version-controlled and repeatable.
Shift-left — the idea of moving testing and security earlier (left) in the development timeline so faults are caught sooner.
Secrets management — storing and providing credentials (API keys, DB passwords) securely to pipelines and deployed services (Vault, AWS Secrets Manager, Azure Key Vault, GCP Secret Manager). Pipelines must not print secrets to logs.
Precise statement often tested: "CI ensures integration happens continuously; CD ensures software is always releasable; Continuous Deployment automates release to production." List assumptions for each: test reliability, automation, rollback capability, and monitoring/observability.
Where exams ask for a diagram of a CI/CD pipeline, draw: source control (left) with branches (feature, main), arrow to CI server box, inside CI server show steps vertically: Checkout → Build → Unit Tests → Static Analysis → Integration Tests → Package → Push to Artifact Registry → Deployment to Staging → Manual Approval → Deploy to Production. Label triggers (push, PR), and indicate where security scans run (static analysis / SCA).
Formulas
For a software/tooling topic we list essential syntax and short snippets students must remember.
git clone <url> — clone a repository. <url> is the repo URL. Use to create local copy.
git checkout -b feature/name — create and switch to a new branch.
git add <files>
git commit -m "message" — make a commit with message.
git push origin feature/name — push branch to remote.
git merge main — merge main into current branch (or vice versa for branch merge).
git rebase main — rebase feature branch onto latest main (use with care).
Minimal GitHub Actions workflow file (remember structure):
name: CI
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: ./build.sh
Minimal Jenkins Declarative Pipeline snippet (remember block names):
pipeline { agent any; stages { stage('Build') { steps { sh 'make' } } } }
Dockerfile minimal syntax lines to remember:
FROM openjdk:11-jre-slim
COPY target/app.jar /app/app.jar
CMD ["java","-jar","/app/app.jar"]
Terraform basic commands to remember:
terraform init — initialize working directory.
terraform plan — show execution plan.
terraform apply — apply the planned changes.
Static analysis and dependency scan commands vary by tool (e.g., sonar-scanner or mvn spotbugs:check, npm audit, trivy image <image>). Remember the tool name and that these should be automated in pipeline.
Worked examples
Example 1 — Code coverage gate (numerical): Problem: A project has 200 executable lines. The pipeline has a gate that fails if coverage < 80%. Tests cover 150 lines. Will pipeline pass? Steps:
- Formula: coverage % = (covered lines / total lines) × 100.
- Numbers: coverage % = (150 / 200) × 100 = 0.75 × 100 = 75%.
- Compare to gate: 75% < 80% → gate fails. Answer: Pipeline fails because coverage is 75%, below 80% threshold.
Example 2 — Trace of a commit through a simple CI/CD pipeline (algorithmic): Pipeline stages: Checkout → Build → Unit tests → Static analysis → Package → Push image → Deploy to staging. Input: Developer pushes commit A to feature branch and opens a pull request to main. Trace (step-by-step):
- Event: push triggers CI job for the PR.
- Checkout stage clones the repo at commit A.
- Build stage runs
mvn packageand creates a JAR; if build fails, pipeline stops and returns failure to PR. - Unit tests run; if any unit test fails, pipeline stops and reports failures to the PR with logs.
- Static analysis runs (e.g., SonarQube or ESLint). If high-severity issues are configured as blocking, the pipeline fails; otherwise it records results.
- Package stage builds a Docker image tagged
registry.example.com/project:commit-A. - Push stage pushes this image to the artifact registry.
- Deploy to staging uses IaC tool to update a deployment manifest to use tag
commit-Aand applies it. Deployment success reported; smoke tests run. - If all pass, pipeline marks PR as green and artefact is available. Manual or automated promotion to production depends on CD policy. Expected exam answer should list each stage, what fails the pipeline and what artifact is produced.
Example 3 — DevSecOps security scan gate (theory model answer): Question: Explain how a vulnerability in a third-party library is handled in a DevSecOps pipeline. Model answer: The pipeline runs a dependency scanning tool (SCA) during CI. If the scanner finds a CVE with severity configured as blocking (e.g., critical), the pipeline fails and reports the failing dependency and CVE ID in the PR. The developer must update the dependency (bump version) or apply a patch. After the change, the pipeline re-runs until it passes. The build system records the vulnerability report in an artefact store for traceability. This is an example of shift-left security: problems are found at commit time, not in production.
Common mistakes
- Running heavy E2E tests on every commit (slow pipeline). Best practice: fast unit tests on each commit; heavier tests on merges or nightly.
- Storing secrets in plaintext in pipeline scripts or logs.
- Not pinning artifact/image tags (using latest) — causes non-reproducible deployments.
- Treating IaC scripts as one-off commands rather than version-controlled code.
For your exam
Question types to expect: definitions and short notes (explain DevOps, CI, CD, DevSecOps), diagrams (draw a CI/CD pipeline and label stages), derivations (reason about feedback loops and lead time reduction), practical snippets (write a minimal GitHub Actions workflow or Jenkins pipeline), and long answer/model questions (design a CI/CD pipeline for a given system including security and rollback strategy).
What a full-marks answer includes:
- Clear, precise definitions of the terms asked (use the bold definitions above).
- A diagram when asked: labelled boxes and arrows, triggers, and where tests and security checks run.
- Practical examples or commands if asked (a minimal YAML or pipeline snippet).
- Discussion of assumptions, trade-offs, and where manual gates are needed (e.g., approvals before production). Mention rollback and monitoring briefly when designing pipelines for production.
Quick check
- What is the difference between Continuous Delivery and Continuous Deployment?
- Where in the pipeline should you run fast unit tests and why?
- Name two types of automated security checks you should include in DevSecOps. Answers: 1) Continuous Delivery prepares deployable artefacts and may include a manual approval step to release; Continuous Deployment automatically releases every green change to production. 2) Fast unit tests should run early in CI (immediately after build) to give quick feedback and fail fast. 3) Static application security testing (SAST)/static analysis and software composition analysis (SCA) for dependency CVEs (also secret scanning and container image scanning).
Finished this topic? Mark it so your progress, study plan and readiness keep up.
Stuck on something here?