To avoid running out of disk space Artifactory allows you to limit the storage space allocated for your repositories.
In the Administration module, under Artifactory | 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 Administration module, select the Repositories and click the repository whose settings you want to edit.
In the Basic settings, check Handle Snapshots and then 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.
Redundant snapshots are not deleted immediately
Every time you deploy a snapshot, Artifactory will check the value Max Unique Snapshots for the repository, and if exceeded will mark any excess old snapshots for deletion. Then, every 5 minutes, Artifactory runs a background process that deletes those oldest snapshots that have been marked. For example, if you set Max Unique Snapshots to 5 and deploy a sixth and seventh snapshot to the repository, then next time the background process runs, it will delete the two oldest snapshots.
Limiting Unique Docker Tags
In the case of Docker registries, you can limit the number of unique tags using the Max Unique Tags field in the Local Docker Repositories configuration.
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 screen under Advanced Settings, specify the number of hours in the Unused Artifacts Cleanup Period 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 Administration module under Artifactory | Maintenance. You can also invoke an immediate run by clicking "Run Unused Cached Artifacts Cleanup"
Recommended Frequency for Deleting Unused Cached Artifacts
Deleting unused cached artifacts is a resource-intensive operation, so to avoid concurrency and performance issues it is recommended to do it no more than once or twice a day, and preferably during "quiet time" such as outside of regular working hours.
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.
- Use the REST API as described Artifacts Not Downloaded Since, to identify artifacts that have not been downloaded since a specific Java epoch, and then remove them.
- Use the REST API as described in Artifacts Created in Date Range to identify artifacts created within a specific date range and then remove them.
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.For more details please refer to the Artifactory Plugin page of the
Jenkins Wiki Documentation.