Interview Prep/CI/CD/Jenkins Pipelines and Agents

A monorepo has 12 services and every commit rebuilds all of them. How do you build only what changed in Jenkins?

IntermediateScenarioJenkins Pipelines and Agents
Answer

Situation read → No change detection.

What I'd do →

  1. Use when { changeset 'services/payments/**' } on each service stage.
  2. For PRs, changeset compares against the change request target; for non-PR builds use git diff --name-only HEAD~1 in a script and compute the set.
  3. For larger repos, adopt a tool that understands the dependency graph (Bazel, Nx, Turborepo).

Why → Build time and cost scale with the change, not the repo size.

Interview tip → Mention shared libraries: a change in common/ must trigger every dependent service.

All CI/CD questions

More on Jenkins Pipelines and Agents