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 →
- Set controller executors to 0 and push all builds to agents.
- Cap build history with
buildDiscarder, and remove unused plugins. - Replace heavy
scriptlogic and@NonCPS-free loops - Groovy runs on the controller. - Size the heap explicitly (
-Xms/-Xmx), enable GC logs and watch with the Metrics or Prometheus plugin. - Move to durable-task friendly steps; avoid
shoutput 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."
More on Jenkins Pipelines and Agents
Your team still builds jobs by clicking through Freestyle jobs in the Jenkins UI. A new service is starting. What do you set up instead?BeginnerA Jenkins build takes 40 minutes because unit tests, linting and security scans run one after another. How do you speed it up?BeginnerBuilds queue for 20 minutes during the morning rush, but the Jenkins nodes are mostly idle at night. What do you do?IntermediateA build works on agent A but fails on agent B with "command not found: mvn". How do you stop this class of problem?BeginnerYou need a pipeline to build a branch automatically on push without polling. How do you wire it?BeginnerOnly the main branch should deploy; feature branches and PRs should only build and test. How do you express this?Beginner