curl -X POST -uuser:password -H "Content-Type: text/plain" -d 'items.find({"repo":{"$match":"non-docker-repo-name"}, "$and" : [ { "modified": {"$before": "180d"}, "created": {"$before": "180d"}}, {"created_by": {"$nmatch" : "_system_"}}], "$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)' > NonDockerImagesTargettedForArchiving.txt
This command finds artifacts that:
- Match the repository name 'non-docker-repo-name'
- 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.
- Are not created by the user '_system_'
- This is for metadata files, which are created by Artifactory
- Has not been downloaded in the past 180 days or has not been downloaded at all