Search code examples
mavennexusnexus3

Nexus 3 : how to get latest snapshot?


As we all know Nexus 3 does not have REST API yet, which is very weird for me. I can only download artifacts manually using wget or curl. But as I'm using Maven 3, all the snapshots artifacts are named using timestamps like this :

myartifact-1.0-20161215.141522-4.tar.gz

So I want to know how I can get latest snapshots from a repo? I want to automate the download process of artifacts but as names change I didn't find any way to achieve this.

Thanks.


Solution

  • If keeping only one SNAPSHOT in the repository is a valid option

    This API call will work: ${nexusUrl}/service/rest/beta/search/assets/download?maven.groupId=${groupId}&maven.artifactId=${artifactId}&maven.baseVersion=${version}

    Though there is finally a Nexus3 API (see more on this in Sonatype's blog), the API does not yet provide the means to get the last SNAPSHOT version. This situation will hopefully be improved in the future: NEXUS-14407 is tracking this feature request.

    But until then I'm workarounding the problem by defining a Maven - Delete SNAPSHOT Task:

    Maven - Delete SNAPSHOT

    and configuring it to run every minute deleting all but 1 snapshot versions older than 0 days:

    enter image description here