Interview Prep/CI/CD/Jenkins Pipelines and Agents

The Jenkins controller keeps running out of memory and slowing down. Builds themselves are not heavy. What is your plan?

IntermediateScenarioJenkins Pipelines and Agents
Answer

Situation read → The controller is doing work it should not, or carrying too much history.

What I'd do →

  1. Set controller executors to 0 and push all builds to agents.
  2. Cap build history with buildDiscarder, and remove unused plugins.
  3. Replace heavy script logic and @NonCPS-free loops - Groovy runs on the controller.
  4. Size the heap explicitly (-Xms/-Xmx), enable GC logs and watch with the Metrics or Prometheus plugin.
  5. Move to durable-task friendly steps; avoid sh output parsing in huge loops.

Why → In Jenkins, Pipeline Groovy CPS code executes on the controller, so scripting-heavy pipelines burden it.

Interview tip → "Keep the controller thin: orchestrate on it, work on agents."

All CI/CD questions

More on Jenkins Pipelines and Agents