
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.
Prerequisite:
- 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



Steps to setup cleanup policy in Nexus Repository Manager
- Visit Nexus RM.
- select the Cog icon (server administration and configuration)
- Under Repository > Cleanup Policy
- Click on Create Cleanup Policy



- Provide the relevant information:
- Name — give the cleanup policy a distinctive name
- Format – The format that this cleanup policy can be applied to
- Cleanup Criteria – What cleanup criteria to enable and their corresponding value/s
- Save
Connect the repository to the cleanup policy:
- Go to the cog icon > Under Repository > Repositories
- Search for the repository name



3. Open the repository > scroll down to Cleanup Policies
4. Search for the cleanup policy created for this repo and APPLY



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 :
- https://help.sonatype.com/repomanager3/nexus-repository-administration/repository-management/cleanup-policies
- https://help.sonatype.com/repomanager3/planning-your-implementation/keeping-disk-usage-low