2. For docker repositories

ARTIFACTORY: How to find old artifacts using AQL

AuthorFullName__c
DaYoun Kang
articleNumber
000006130
ft:sourceType
Salesforce
FirstPublishedDate
2024-06-23T07:59:38Z
lastModifiedDate
2024-06-23
VersionNumber
1
curl -X POST -uuser:password -H "Content-Type: text/plain" -d 'items.find({"repo":{"$match":"docker-repo-name"}, "$or": [{"name":{"$eq":"manifest.json"}, "name":{"$eq":"list.manifest.json"} } ], "$and" : [ { "modified": {"$before": "180d"}, "created": {"$before": "180d"} }], "$or" : [ {"stat.downloaded":{"$before": "180d"}, "stat.downloads": { "$eq": null } } ] } ).include("repo", "path", "name", "created", "modified", "stat.downloaded")' "http://ARTIFACTORY_URL/artifactory/api/search/aql" | jq -r '.results[]| (.repo + "/" + .path)' > DockerImagesTargettedForArchiving.txt

This command finds artifacts that:
  • Match the repository name 'docker-repo-name'
  • Have a name of 'manifest.json' or 'list-manifest.json'
  • Have not been modified in the last 180 days and created before 180 days
    • The reason for this condition is that, if we deploy a new artifact to this repository and if we run this command right after, then without this condition, this command will also delete the newly deployed artifact. You can modify the number of days for this condition.
  • Has not been downloaded in the past 180 days or has not been downloaded at all
After running the curl command, it will save the path of artifacts found in a file called 'DockerImagesTargettedForArchiving.txt'.

Further, if needed, customers can use the Delete Item REST API to delete those artifacts.