Interview Prep/CI/CD/Jenkins Pipelines and Agents

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 →

  1. Stop depending on tools installed on the node. Run stages in containers: agent { docker { image 'maven:3.9-eclipse-temurin-21' } }.
  2. Or use the Jenkins tools { maven 'M3' } block, which installs a pinned version.
  3. 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.

All CI/CD questions

More on Jenkins Pipelines and Agents