34

We are using Nexus to deploy our snapshot artifacts. Our build server deploys them during each build using the following command: mvn deploy. As result on each build the newer version of the artifact is deployed. The problem that already about dozens of artifacts are deployed to the repository and of course we need only the last artifact. Is any way to limit number of deployed snapshots artifacts in Nexus? Thanks for your help, Michael

Michael
  • 10,063
  • 18
  • 65
  • 104

4 Answers4

40

Create a scheduled task to purge out old snapshots.

The following links describe the functionality:

You can configure the task to always keep a minimum number of artifacts. It's very flexible.

The only "gotcha" in Version 2 of the Repository Manager, is that you'll need to also run a second task, Empty Trash, in order to claim back the disk space. For Version 3 you will need to run Compact blob store to ensure that the deletion will return the disk space. See docs above.

Olaf Ziems
  • 69
  • 8
Mark O'Connor
  • 76,015
  • 10
  • 139
  • 185
  • 2
    JFTR, that task has a 'delete immediately' flag since Nexus 2.0 ([NEXUS-4579](https://issues.sonatype.org/browse/NEXUS-4579)). – nabcos Oct 01 '12 at 11:16
23

If you have the administrator access in Nexus Then,

  1. Login to Nexus.

  2. Browse to Administration.

  3. Go to scheduled Tasks.

  4. You can add the task : Remove Old Snapshots.

  5. Select task type as Remove Snapshots from repository.

  6. You can define Minimum Snapshot count or Snapshot retention as needed.

Raghav S
  • 401
  • 3
  • 6
3

I suspect not. http://weblogs.java.net/blog/johnsmart/archive/2010/01/03/tale-two-repository-managers-nexus-and-artifactory-compared-and-co

Artifactory [...] also lets you limit the number of snapshots per artifact for each repository.

This is said in contradiction to Nexus.

chx
  • 11,270
  • 7
  • 55
  • 129
  • All Maven repository managers can purge snapshots. It's why there are two types of Maven hosted repository. – Mark O'Connor Sep 30 '12 at 14:17
  • The answer is correct if we take the question: *How to limit number of deployed snapshots artifacts in Nexus?* in an exact sense. You cannot limit the number, you can only schedule the snapshot delete task.... – dedek Jan 29 '19 at 12:56
0

With Nexus OSS 3.x there are:

  • Delete unused SNAPSHOT Task - no one access SNAPSHOT X days
  • Delete SNAPSHOT Task - leave only N last SNAPSHOTS

and each task has:

  • CRON
  • list of repositories to apply to
gavenkoa
  • 45,285
  • 19
  • 251
  • 303