Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't Jenkins download my latest snapshot?

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):

  • Expired Cache in Nexus
  • Checked the local repository (in the job directory) - there was no artifact directory
  • Set "Build -> Goals and options" to "-U clean install" in the job configuration
  • Wait one hour

My setup:
Windows Server 2003
Java 1.6.0_31
Jenkins 1.480
Maven 3.0.3

like image 790
Zeemee Avatar asked Sep 06 '12 14:09

Zeemee


2 Answers

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.

like image 112
Mark O'Connor Avatar answered Oct 06 '22 20:10

Mark O'Connor


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>
like image 45
PaoloC Avatar answered Oct 06 '22 19:10

PaoloC