Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to limit number of deployed snapshots artifacts in Nexus?

Tags:

java

maven

nexus

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

like image 339
Michael Avatar asked Sep 30 '12 11:09

Michael


People also ask

What is Nexus snapshot?

When deployed, the snapshot is turned into a timestamp. By definition, snapshots are mutable, releases are immutable. This is why Nexus makes you store them separately because usually you don't care if you lose snapshots, but you will care if you lose releases.

Why deploy artifacts in Nexus for deployment?

Nexus is a repository manager that stores “artifacts”, which allows you to proxy collect and manage your dependencies, making it easy to distribute your software.

How do I delete old artifacts from Nexus?

First you have to define a cleanup policy. Then you have to attach the cleanup policy to one or more repositories. The “Cleanup repositories using their associated policies” task will then execute the cleanup policies. The documentation about Cleanup Policies can be found here.


3 Answers

Create a scheduled task to purge out old snapshots.

The following links describe the functionality:

  • Nexus scheduled tasks
  • Managing scheduled tasks - Repository Manager 2
  • Types of Tasks and When to Use Them - Repository Manager 3 (Task "Maven - Delete SNAPSHOT")

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.

like image 117
Mark O'Connor Avatar answered Sep 18 '22 18:09

Mark O'Connor


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.

like image 34
Raghav S Avatar answered Sep 21 '22 18:09

Raghav S


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.

like image 34
chx Avatar answered Sep 21 '22 18:09

chx