Interview Prep/Build Tools (Java, Node.js, Python, .NET)/Java builds (Maven, Gradle, JAR, WAR)

A developer says "it builds on my machine but fails in CI". How do you approach it?

IntermediateScenarioJava builds (Maven, Gradle, JAR, WAR)
Answer

Short answer

Find what's different between the two environments: tool versions (JDK, Node, Python, Maven), dependencies (lockfile not committed, private repo access), OS differences (case-sensitive filenames, line endings), uncommitted files, environment variables, and caches. Then make CI and local builds use the same pinned versions.

Checklist

Difference How to check / fix
Tool versions Compare java -version, node -v; pin via .nvmrc, Maven wrapper, setup-java
Uncommitted files git status on the dev machine; CI only sees what's committed
Lockfile Committed and used (npm ci, frozen installs)?
Private dependencies Does CI have credentials for Nexus/Artifacts? Check 401s in logs
Case sensitivity import ./Utils vs utils.js — fine on macOS/Windows, fails on Linux
Environment variables Build relies on a local env var or .env that CI doesn't have
Local cache hiding a problem Clear local cache (rm -rf ~/.m2/repository/..., npm ci) and rebuild
Tests depend on local services/timezone Use service containers; set TZ explicitly

Long-term fix

Build in a container locally and in CI (same image), or use dev containers — removes "my machine" from the equation.

What to say in the interview

"I diff the environments: tool versions, committed files, lockfiles, credentials for private feeds, OS case sensitivity and env vars. Then I pin versions in the repo so CI and laptops match, ideally building inside the same container image."

All Build Tools (Java, Node.js, Python, .NET) questions Roadmap: Java apps: Maven, Gradle, JAR & WAR

More on Java builds (Maven, Gradle, JAR, WAR)