How does this feature work?

ARTIFACTORY: How does the “Max Unique Snapshots” parameter work in Artifactory?

AuthorFullName__c
Fadi Rouhana
Best_Article_1__c
https://jfrog.com/confluence/display/JFROG/Managing+Disk+Space+Usage <recomsep> Managing Disk Space Usage
Best_Article_2__c
https://jfrog.com/confluence/display/JFROG/Artifactory+Query+Language <recomsep> Artifactory Query Language
Best_Article_3__c
https://jfrog.com/knowledge-base/artifactory-cleanup-best-practices/ <recomsep> Artifactory Cleanup Best Practices
articleNumber
000005403
ft:sourceType
Salesforce
FirstPublishedDate
2022-09-12T09:58:55Z
lastModifiedDate
2023-01-22T11:06:53Z
VersionNumber
2
To demonstrate how this feature works, let’s take an example Maven snapshots repository with "Max Unique Snapshots" set to 2. In this repository, we have already deployed 2 Maven snapshots, which has resulted in the following structure under the Maven snapshots repository:

User-added image


As seen above, when you deploy a snapshot, for example, a timestamp of the deployment will be appended to the file name in addition to the version number.

At this point, we have reached the "Max Unique Snapshots" limit so for any new snapshot deployed, the cleanup should be triggered. Therefore, we have redeployed another snapshot of the artifact that was deployed according to the previous naming, with "-3" applied to its name to indicate that this is the third version of the artifact:

User-added image


This is where "Max Unique Snapshots" comes into the picture, as the first version of the artifact was deleted as part of the cleanup process, resulting in the following:

User-added image


Finally, we can see that the repository contains only the second and third versions of the snapshot as the first version was removed due to the "Max Unique Snapshots" policy set for the repository.

This can also be monitored via the
$JFROG_HOME/artifactory/var/log/artifactory-service.log file, as seen below:
2022-08-15T06:03:33.495Z [jfrt ] [INFO ] [69f57c5982eefe5d] [egrationCleanupServiceImpl:214] [art-exec-42829      ] - Removed old unique snapshot 'org/eclipse/jetty/jetty-ajp/3.1-SNAPSHOT/jetty-ajp-3.1-20220815.055110-1.jar'.
2022-08-15T06:03:33.504Z [jfrt ] [INFO ] [69f57c5982eefe5d] [egrationCleanupServiceImpl:214] [art-exec-42829      ] - Removed old unique snapshot 'org/eclipse/jetty/jetty-ajp/3.1-SNAPSHOT/jetty-ajp-3.1-20220815.055110-1.pom'.

Note:
To avoid issues of concurrency, Artifactory requires that you store a minimum of 2 unique snapshots.