How to Setup Nexus RM Cleanup Policy

person holding black pen reviewing a document
Reading Time: 3 minutes

What is the Nexus repository manager?

A repository manager called Nexus by Sonatype groups, stores, and disperses the assets required for the development. Software distribution is made simpler by Nexus, which enables developers to fully control deployment and access to every artifact within an organization from a single location.

Types of Nexus Repository Manager

Proxy repositories, Hosted repositories, and Virtual repositories are the three types of repositories that Nexus Repository Manager supports.


Advantages of Nexus Repository Manager

The repository manager is Nexus. You can proxy, gather, and manage your dependencies with its help, allowing you to stop continually juggling a bunch of JARs. You set up your build internally to make artifacts available to other developers by publishing them to Nexus.

Setup Nexus Repository Manager Cleanup Policy

Under the Cleanup Policies menu item in the Repository area of the Administration menu, a Cleanup Policy can be created for a specific format or, alternatively, for all formats to be used generally. The criteria for each policy are ANDed together, discarding only components that satisfy all the prerequisites (e.g. items that arrived before X days AND were downloaded before Y days).

NOTE: Everything that cleanup policies delete is soft deleted. Up until the execution of an Admin – Compact blob store task, disc space is not recovered.


  • Name  of configuration: a unique name for the cleanup policy
  • Format: The format that this cleanup policy can be applied to (example: maven2, npm, helm)
  • Cleanup Criteria: Which cleanup criterion should be enabled and what value(s) should they have
cleanup criteria

Steps to setup cleanup policy in Nexus Repository Manager

  1. Visit Nexus RM. 
  2. select the Cog icon (server administration and configuration)
  3. Under Repository > Cleanup Policy
  4. Click on Create Cleanup Policy
create cleanup policy
  • Provide the relevant information:
    1. Name — give the cleanup policy a distinctive name
    2. Format – The format that this cleanup policy can be applied to
    3. Cleanup Criteria – What cleanup criteria to enable and their corresponding value/s
  • Save

Connect the repository to the cleanup policy:

  1. Go to the cog icon > Under Repository > Repositories
  2. Search for the repository name
preview repository

3. Open the repository > scroll down to Cleanup Policies

4. Search for the cleanup policy created for this repo and APPLY

cleanup policies

5. Save

Important information to remember

  • ALL cleanup policies created and associated to repos will run DAILY. This is based on the Task named Cleanup service which runs all the cleanup policies associated to repo
  • The Cleaning Policy SOFT DELETES ANY component which is not present.
  • The job Cleanup Space (blobs) must finish running before disc space may be recovered.

Conclusion :

Nexus repository cleanup policy helps in keeping the instance light weighted by deleting or cleaning up the unwanted or old data. This helps in managing the repository size by performing cleanup.

Reference :