Builds on a single agent are slow because every build downloads the same Maven dependencies. What do you do?
IntermediateScenarioJenkins Pipelines and Agents
Answer
Situation read → No dependency cache, or a cold ephemeral agent each time.
What I'd do →
- Point Maven at a Nexus/Artifactory proxy repository in
settings.xmlso downloads are LAN-fast and cached. - On static agents keep
~/.m2persistent; on Kubernetes mount a shared PVC or use a pre-warmed image. - Use
mvn -B -T 1Cfor parallel module builds and the Maven build cache extension where appropriate.
Why → A repository proxy is the most robust cache because it is shared by all agents and CI users.
Interview tip → Proxying also protects you if Maven Central is unavailable.
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