Maven "BUILD FAILURE - Could not find artifact (SNAPSHOT)" - Fix in CI
Maven could not resolve a -SNAPSHOT dependency. Either the snapshot was never published to the repository CI can reach, the snapshot repository is not declared, or the metadata fetch dropped mid-transfer on a flaky network.
What this error means
The build fails with BUILD FAILURE and Could not find artifact com.example:lib:jar:1.2.0-SNAPSHOT in snapshots, or Could not transfer metadata ... maven-metadata.xml when the snapshot repo is unreachable.
[ERROR] Failed to execute goal on project app: Could not resolve dependencies
for project com.example:app:jar:1.0.0: Could not find artifact
com.example:lib:jar:1.2.0-SNAPSHOT in snapshots
(https://nexus.example.com/repository/maven-snapshots/)Diagnose it: resolve the effective POM first
Maven merges parent POMs, profiles, and settings before it builds anything. The configuration causing your failure is frequently inherited or activated by a profile that is on locally and off in CI.
# the fully resolved configuration Maven will actually use
mvn help:effective-pom | head -60
# which profiles are active here vs on your machine?
mvn help:active-profiles
# full error, offline-safe, no colour codes to confuse the log
mvn -B -e -X <goal> 2>&1 | tail -60Common causes
The SNAPSHOT was never deployed
The upstream module that produces the snapshot has not run mvn deploy, so no build of it exists in the snapshot repo.
Snapshot repository not declared or snapshots disabled
The repo entry has <snapshots><enabled>false</enabled></snapshots>, or the snapshot repo is simply not configured, so Maven never looks there.
Transient network drop fetching snapshot metadata
Snapshots are re-resolved every build via maven-metadata.xml; a momentary network blip during that fetch fails resolution even though the artifact exists.
How to fix it
Enable and declare the snapshot repository
Make sure Maven is told where snapshots live and that snapshots are enabled.
<repository>
<id>company-snapshots</id>
<url>https://nexus.example.com/repository/maven-snapshots/</url>
<snapshots><enabled>true</enabled></snapshots>
</repository>Force a fresh snapshot re-resolve
Rule out stale or partial snapshot metadata in the local cache.
mvn -U clean verify
# -U forces an update check for SNAPSHOT metadataDeploy the upstream snapshot first
If the artifact truly is absent, publish it from the producing module.
mvn -q deploy # in the lib module, so the SNAPSHOT exists for consumersHow to prevent it
- Prefer released versions over SNAPSHOTs for shared CI dependencies.
- Declare snapshot repositories explicitly with snapshots enabled.
- Use a proxy repo so snapshot metadata is cached and resolution is resilient.