Skip to content
Ameen Abozaid
JNR-051

CI/CD introduction

  • 7 Lessons
  • 3 h practice (estimate)
On this page 8 topics

Overview

Topics

  • GitHub Actions or GitLab CI
  • build/test pipeline
  • artifacts

Learn first

3 h of practice (estimate)

Learning outcomes

  1. Explain continuous integration, delivery, and deployment.
  2. Write a GitHub Actions workflow that builds, runs all tests (including Testcontainers), and caches dependencies.
  3. Publish build artifacts (JAR, container image) to a registry with version tags.
  4. Protect main with required checks.

Lessons

  1. 01CI, CD, and CD
  2. 02GitHub Actions anatomy
  3. 03Build and test pipeline
  4. 04Artifacts and image publishing
  5. 05Branch protection
  6. 06Demo: building the Shop pipeline in GitHub Actions
  7. 07Demo: publishing a tagged image on merge

Lab and exercises

Lab

JNR-051-LAB1 · Shop pipeline

Outcomes: 1–4 · Time: ~3 h Every PR runs the full suite (including Testcontainers) with caching; merges to main publish a tagged image; main is protected with required checks. Acceptance: a PR with a failing test cannot be merged.

Exercises (assessment: fix a broken workflow)

IDOutcomeTask
JNR-051-EX011Explain CI, continuous delivery, and continuous deployment in one sentence each, with a Shop example.
JNR-051-EX022Write a workflow that checks out, sets up Java 21 with Maven cache, and runs ./mvnw -B verify on pull requests.
JNR-051-EX032Confirm Testcontainers tests run in the workflow and find the test count in the log.
JNR-051-EX043Add a job that builds the image and pushes it to ghcr.io tagged with the commit SHA on pushes to main.
JNR-051-EX054Configure branch protection requiring a PR, one review, and the build check.
JNR-051-EX062Given a broken workflow (wrong indentation, -DskipTests, missing permissions), find and fix each defect.
Show solutions
  • EX01 CI: merge often and test automatically. Delivery: every green build is releasable, a human approves. Deployment: every green build goes live automatically.
  • EX02 on: pull_request; steps actions/checkout, actions/setup-java with cache: maven, run: ./mvnw -B verify.
  • EX03 Runners have Docker; the Surefire/Failsafe summary shows "Tests run: N"; N must be above zero.
  • EX04 if the event is a push to main; permissions: packages: write; docker/login-action with GITHUB_TOKEN; docker/build-push-action with tags: ghcr.io/${{ github.repository }}:${{ github.sha }}.
  • EX05 Settings, Branches (or Rulesets): require pull request, 1 approval, status check build, block force pushes.
  • EX06 Fix YAML indentation, remove -DskipTests, add permissions: packages: write for pushing images.
  • Common mistakes (secrets printed in logs, zero tests run) are checked in the EX06 review.

Quiz

Outcomes: O1 CI/CD concepts · O2 workflows · O3 artifacts and images · O4 branch protection.

A self-check for you: nothing is graded, saved or sent anywhere. Choose an answer, then check it. You can try again as often as you like.

  1. 1Continuous deployment means:O1
  2. 2Continuous integration mainly:O1
  3. 3Workflow files live in:O2
  4. 4A step that uses a reusable action starts with:O2
  5. 5Why cache dependencies?O2
  6. 6A pipeline that passes with zero tests run is:O2
  7. 7A safe tag for traceability is:O3
  8. 8To push to GHCR from Actions use:O3
  9. 9To stop failing PRs from merging:O4
  10. 10Branch protection can also:O4

Practical part

Six exercises JNR-051-EX01 to EX06 plus the lab; for the assessment, fix a broken workflow. Pass: quiz 8/10, at least five exercises correct, and a failing-test PR blocked from merging.

Common mistakes

Secrets printed in logs; pipelines that pass with zero tests run.

Assessment

Fix a broken workflow.

Career relevance

CI/CD advanced (MID-055).

Type to search levels, phases, modules and lessons.