Reputation: 8042
We use Maven/Nexus/Hudson in our team. The Maven version on our Hudson server is 3.0.4 and has stopped being able to download snapshot dependencies when building jobs. I'm not sure what has changed (no on the team has done anything, so they say), but something has happened because builds that worked Monday morning stopped working Monday afternoon.
When I try to build a project in Hudson that has a snapshot dependency, I get this error:
[WARNING] The POM for com.company:my-client:jar:1.9-SNAPSHOT is missing, no dependency information available
I believe I have nailed the issue down to the fact that Maven isn't downloading the maven-metadata.xml
file and therefore can't resolve the dependency to the timestamp version. For example, in my local build (using Maven 3.0.3), I see this in my Maven output:
Downloading: http://ip:8080/nexus/content/groups/public/com/company/my-client/1.9-SNAPSHOT/maven-metadata.xml
Downloaded: http://ip:8080/nexus/content/groups/public/com/company/my-client/1.9-SNAPSHOT/maven-metadata.xml (1004 B at 20.0 KB/sec)
Downloading: http://ip:8080/nexus/content/groups/public/com/company/my-client/1.9-SNAPSHOT/my-client-1.9-20130625.202822-1.pom
Downloaded: http://ip:8080/nexus/content/groups/public/com/company/my-client/1.9-SNAPSHOT/my-client-1.9-20130625.202822-1.pom (3 KB at 57.5 KB/sec)
...
Downloading: http://ip:8080/nexus/content/groups/public/com/company/my-client/1.9-SNAPSHOT/my-client-1.9-20130625.202822-1.jar
...
Downloaded: http://ip:8080/nexus/content/groups/public/com/company/my-client/1.9-SNAPSHOT/my-client-1.9-20130625.202822-1.jar (10 KB at 153.9 KB/sec)
Both builds are accessing our Nexus repo and the Hudson Maven has no problems accessing non-snapshot dependencies from it, so it's not a connection issue.
Why would Maven not recognize the SNAPSHOT and download the maven-metadata.xml
to get the latest timestamp version of the dependency?
Upvotes: 4
Views: 11829
Reputation: 1826
I hit this problem as well. We inadvertently solved the issue by adding the source repositories into our project POM. Despite still routing through our mirror, this change allowed the project to resolve the metadata to the latest snapshot version.
Example:
<project>
<repositories>
<repository>
<id>XYZ-SNAPSHOTS</id>
<url>http://nexus.xyz.org/nexus/content/groups/enterprise-snapshots/</url>
<releases><enabled>false</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
</project>
After the fact, I discovered that we had not configured the mirror correctly. The real issue seems to be that snapshots were not enabled on the mirror in the settings.xml, even though they were enabled in Nexus itself.
When I added the repos in the project, I enabled snapshots without thinking about it, which then allowed Maven to resolve the snapshots. This fixed it, but the better solution is to update settings.xml to fix it for all mirrored repos.
For reference, here is the proper settings.xml configuration (taken from Sonatype):
<settings>
<mirrors>
<mirror>
<!--This sends everything else to /public -->
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://localhost:8081/repository/maven-public/</url>
</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>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<!--make the profile active all the time -->
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>
Upvotes: 3
Reputation: 8042
After much hair-pulling, we discovered that our settings.xml file for the hudson user had the nexus profile removed. This appears to have the effect of not being able to query the snapshot repo although it could get artifacts from the release repo.
The last edit of the file before we fixed it was May 29th so it's still a mystery as to why the jobs built in the morning of June 24th but not in the afternoon. Perhaps something was being cached and that was refreshed.
Upvotes: 2