Deleting Unused Artifacts

Artifactory Cleanup Best Practices

AuthorFullName__c
Patrick Russell
articleNumber
000004531
ft:sourceType
Salesforce
FirstPublishedDate
2019-08-23T07:13:48Z
lastModifiedDate
2024-03-10T07:45:49Z
VersionNumber
7
Artifactory will not delete binaries automatically unless you make use of the above-referenced fields to define exceptions. Additionally, you can save a lot of storage space by deleting artifacts that haven’t been downloaded for a long period of time. The best way to automatically clean out these unused files is to use an Artifactory user plugin.

Of these, one of the most popular is the artifactCleanup plugin, which runs on a cron job, automatically deleting any artifact that has not been downloaded for "x" number of days. If you’d like to customize this plugin further, you can change the Artifactory Query Language (AQL) statement in the code:

def aql = "items.find({"repo":"" + repoKey + "","type": "any","@cleanup.skip":"true"}).include("repo", "path", "name", "type")"

Note: artifactCleanup does not work on Docker repositories. Docker image layers are stored as separate artifacts within an image folder. If a layer is already in most Docker clients, it won't get downloaded often. Due to this behavioral difference, we recommend using the cleanDockerImages plugin. Relying on the download count of the manifest.json file, the Docker client will always download it when a docker pull occurs.