I have a Jenkins build job for a maven 3 project. The project has a SNAPSHOT dependency. The build failed because Maven can't find the SNAPSHOT artifact, which is deployed to a intranet Sonatype Nexus Repository. The SNAPSHOT repository is part of the "public" group, which is the mirror URL for <mirrorOf>*</mirrorOf>
.
Jenkins is configured to create a local Maven repository local to the workspace (one repostiory per job).
All other non-snapshot dependencies are resolved and downloaded well. Other jobs for projects without SNAPSHOT-dependencies are also built successfully.
Things I tried so far (without success):
My setup:
Windows Server 2003
Java 1.6.0_31
Jenkins 1.480
Maven 3.0.3
This could be the "gotcha" I also discovered, downloading snapshot revisions from Nexus.
The solution is provided in the Nexus book, but not fully explained:
<settings>
<mirrors>
<mirror>
<id>nexus</id>
<url>http://myserver/nexus/content/groups/public</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<!--Enable snapshots for the built in central repo to direct -->
<!--all requests to nexus via the mirror -->
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<!--make the profile active all the time -->
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>
Seems one must explicitly tell Maven that the Nexus provided repository group can also contain Snapshot revisions. Presumably what this does is trigger Maven to start looking for the special metadata files that are used to discover which timestamped file is in fact the latest snapshot.
Since you already defined mirrorOf/*
, just add this in your .m2/settings.xml
to instruct maven to search that mirror also for snapshot:
<profile><id>alwaysactive</id>
<activation><activeByDefault>true</activeByDefault></activation>
<repositories>
<repository><id>unused</id><url>unused</url></repository>
</repositories>
</profile>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With