Artifactory includes features to help you manage the amount of disk space used by your system. This is done by providing alerts, limiting the amount of space allocated for the output of automatic procedures, and by cleaning up unused artifacts in a controlled manner.
When an Artifactory user "deletes" a file, what is actually deleted is the reference from the Artifactory database to the physical file. Before actually deleting a file Artifactory must scan the system to ensure that there are no other users referencing the file. Scanning the system is very CPU intensive, and locks files while the scan is in process, and this may stress the development environment. Therefore this can be scheduled to run periodically as a "Garbage Collection" process during times when demands on the system are low.
This is done in the Artifactory UI Admin tab under Advanced | Regular Maintenance Operations, where you can schedule an automatic run of Garbage Collection with a Cron expression. You can also invoke an immediate run by clicking "Run Storage Garbage Collection".
To avoid running out of disk space Artifactory allows you to limit the storage space allocated for your repositories.
In the Admin tab, under Advanced | Maintenance, set Enable Quota Control, and specify Storage Space Limit to specify the percentage of disk space that you allocate for your repositories. An attempt to store binaries above the allocated storage percentage will fail with an error. You may also set Storage Space Warning to specify at what percentage of disk space usage to receive a warning from Artifactory.
Limiting the Number of Snapshots
Working with snapshots is a standard development practice, however depending on the number of snapshots that are saved, this can use up large quantities of disk space.
To specify the maximum number of snapshots that may be stored, in the Edit Repository dialog, select the Basic Settings tab.
You first need to check the Handle Snapshots checkbox which then enables you to set the Max Unique Snapshots field. This value is zero by default, which means that all snapshots are saved.
To avoid issues of concurrency, Artifactory requires that you store a minimum of 2 unique snapshots, however can can control the maximum number of snapshots that are stored.
Deleting Unused Cached Artifacts
When working with remote repositories, to optimize performance, Artifactory locally caches and aggregates snapshots of remote artifacts that are being used. However, if at some point, these artifacts are no longer used, Artifactory can identify and remove them.
You can control how long an unused artifact will remain cached before it is eligible for cleanup. In the Edit Repository dialog under the Advanced Settings tab, specify the number of hours in the Keep Unused Artifacts field.
By default this value is set to zero which means that an artifacts from the corresponding repository are never removed from the cache.
Cleaning up unused cached artifacts can be scheduled to run automatically during times when demands on the system are low using a Cron expression in the Admin tab under Advanced | Maintenance. You can also invoke an immediate run by clicking "Run Unused Cached Artifacts Cleanup"
Deleting Complete Versions
Artifactory supports a complete manual deletion of an installed version. This is fully described in Deleting a Version.
Artifactory supports cleanup by allowing you to write custom User Plugins which you can develop to meet your own specific cleanup requirements.
JFrog provides a number of cleanup scripts on GitHub which you can use as provided or modify to suit your own needs. For example the following artifactCleanup plugin deletes artifacts that have not been downloaded for a specified number of months.
Manual Cleanup with the REST API
Using the Artifactory REST API, you may write scripts to implement virtually any custom cleanup logic. This provides you with an extensive and flexible set of customization capabilities as provided by the REST API.
Discarding old builds with Jenkins Artifactory plugin
When using Jenkins for continuous integration, you can configure a policy to discard old builds that are stored in Artifactory along with their artifacts.