Artifactory Cleanup Best Practices

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

Software development can be a messy business. Often, there will be many artifacts residing in Artifactory that will never be used. And even though Artifactory makes great use of checksum-based storage, this can’t replace your need to regularly perform artifact cleanup duties. For example, although CI/CD builds are configured to run based on source control commits, these snapshot builds are never actually downloaded once they are sent to Artifactory.


As data retention policies differ from company to company, it’s incumbent upon you to determine what data needs to be cleaned up. Thereafter, Artifactory’s built-in tools can help you to handle the majority of cases you’ll want to address.

In general, there are three kinds of techniques that are used to manage artifact storage in Artifactory:
  • Clearing oversized caches
  • Deleting unused artifacts
  • Limiting the number of build snapshots that are retained

The purpose of the last of these is to ensure that release artifacts are promoted out of the snapshots repository before it is overwritten.

Artifactory supports the Max Unique Snapshots tag for six repository types:
- Maven         - NuGet
- Gradle         - Ivy
- Docker        - SBT

As Artifactory uses a Repository Layouts system to track snapshots, you’ll need to adhere to a defined pattern when uploading artifact snapshots . For most clients, once these limitations have been programmed into the system, the rest will occur automatically and seamlessly. For example, the following Maven JAR file is recognized as a part of snapshot run number 3:
jfrog/hello/1.0.5-SNAPSHOT/hello-1.0.5-20190620.224837-3.jar

User-added image

Most CLI clients will upload snapshots that adhere to specific checksum policies and snapshot version behaviors, which Artifactory's default layouts should be able to address. Otherwise, as required, you can customize repository type layouts to handle specific upload paths. To enable this customization option in Artifactory, update your local repository settings:

User-added image

When this setting is enabled, during any given build run that results in uploads reaching the Max Unique Snapshots number you entered, older releases will automatically be deleted. The highest number will always be your latest release.