Spring Boot Tutorial 0/110 lessons ~6 min read Lesson 79

    CI/CD Pipelines

    CI/CD is the automated path from TechLearningPRO Orders commits to production: lint, test, scan, build image, push, deploy.

    Course progress0%
    Focus
    12 guided sections
    Practice signal
    Examples included
    Career prep
    Interview Q&A included

    Introduction

    CI/CD is the automated path from TechLearningPRO Orders commits to production: lint, test, scan, build image, push, deploy. Humans approve risky gates; robots do the boring parts the same way every time.

    A canonical Boot 3 pipeline runs Checkstyle/Spotless, unit tests, Testcontainers integration tests, SAST, image build (buildpacks), Trivy scan, registry push, auto-deploy to dev, smoke tests, then staged promotion to prod.

    Whether you use GitHub Actions, GitLab CI, Jenkins, or CircleCI, the stages matter more than the brand. Shift security left so vulnerabilities never reach the registry.

    This lesson designs the Orders pipeline before tool-specific GitHub Actions and Jenkins labs.

    Purpose of this lesson

    Design a complete CI/CD pipeline for Orders that builds, tests, scans, and promotes Boot 3 images safely.

    Understanding the topic

    Every commit should travel the same highway.

    • CI: verify quality on every push/PR.
    • CD: deliver artifacts to environments with policy gates.
    • Shift left: SAST + dependency + image scans before deploy.
    • Promotion: same artifact digest from dev → staging → prod.
    • Approvals: manual gates for production.

    Step-by-step explanation

    1. List pipeline stages for Orders from lint through prod deploy.
    2. Fail the build on test or high-severity scan findings.
    3. Publish an image tagged with git SHA; never rebuild differently per environment.
    4. Auto-deploy to dev; require approval for production.

    Informative example

    Canonical Orders pipeline stages.

    bash
    git push
    │
    ▼
    ┌──────────────────────────────────────────┐
    │ 1. Lint (checkstyle, spotless) │
    │ 2. Unit tests (./mvnw test) │
    │ 3. Integration (Testcontainers) │
    │ 4. SAST (CodeQL / Semgrep) │
    │ 5. Build image (buildpacks) │
    │ 6. Image scan (Trivy) │
    │ 7. Push to registry (tag = git SHA) │
    │ 8. Deploy: dev (auto) │
    │ 9. Smoke (/actuator/health + create order)│
    │10. Deploy: staging → prod (approval) │
    └──────────────────────────────────────────┘
    # Promotion rule
    # prod image digest == staging digest == CI digest

    Real-world use

    Before CI, TechLearningPRO engineers ran 'mvn package' locally and SCP'd jars. One laptop had a dirty tree and shipped a half-finished pricing client. A mandatory pipeline with Testcontainers and a prod approval gate ended those surprises.

    Security implications

    Pipelines are privileged production actors.

    • Short-lived OIDC cloud credentials — avoid long-lived access keys in CI.
    • Restrict who can approve prod deploys.
    • Never echo secret values in build logs.

    Best practices

    • Immutable artifact promotion by digest.
    • Fast feedback on PRs; heavier integration on main.
    • Encode the pipeline in version control next to the app.

    Common mistakes

    • Rebuilding artifacts per environment so prod is not what you tested.
    • Skipping scans 'just this once' on Friday.
    • Deploying from developer workstations with ad-hoc credentials.

    Advanced interview questions

    Interview Prep

    Practice concise answers, then expand each card for the explanation.

    3 questions
    1BeginnerQuestionWhat is the difference between CI and CD?+

    Answer

    CI continuously verifies changes; CD continuously delivers verified artifacts to environments under policy.
    2IntermediateQuestionWhy promote the same image digest?+

    Answer

    So production runs exactly what staging validated — no 'works after rebuild' drift.
    3BeginnerQuestionWhat does shift-left security mean in CI?+

    Answer

    Run SAST and image scans early so issues fail the build before deploy.

    Hands-on exercise

    Lab. Draw the Orders pipeline with ten stages. Mark which stages run on pull requests vs main, and which require a human approval. Identify one scan tool for code and one for images.

    Summary

    CI/CD pipelines industrialize TechLearningPRO Orders delivery. Next: implement the pattern with GitHub Actions.

    Ready to mark this lesson complete?Track your journey across the entire course.