A build works on agent A but fails on agent B with "command not found: mvn". How do you stop this class of problem?
BeginnerScenarioJenkins Pipelines and Agents
Answer
Situation read → Snowflake agents with different installed tools.
What I'd do →
- Stop depending on tools installed on the node. Run stages in containers:
agent { docker { image 'maven:3.9-eclipse-temurin-21' } }. - Or use the Jenkins
tools { maven 'M3' }block, which installs a pinned version. - Build agent images from one Dockerfile or Packer template in Git.
Why → The toolchain becomes part of the pipeline definition, so every agent behaves the same.
Interview tip → "Immutable agents" is the phrase.
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?IntermediateYou 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?BeginnerA pipeline sometimes hangs forever on a flaky network call and holds an executor. How do you protect the system?Beginner