I have a need to delete the artifact versions for one of my repos in artifactory that are older than certain number of days. By this i mean that suppose my artifactory url repo is :-
https://artifactory.mycompany.com/artifactory/myrepo/
and under that repo there are few folders with the name pattern abc-*-xyz, which means the fully qualified paths here for those folders would be :-
https://artifactory.mycompany.com/artifactory/myrepo/abc-1-xyz
https://artifactory.mycompany.com/artifactory/myrepo/abc-2-xyz
https://artifactory.mycompany.com/artifactory/myrepo/abc-3-xyz
Now under each of these folders are stored the actual versioned artifact folders that i would like to only delete, which means that entire version folder for example for two of the urls that would be :-
https://artifactory.mycompany.com/artifactory/myrepo/abc-1-xyz/ver_11
https://artifactory.mycompany.com/artifactory/myrepo/abc-1-xyz/ver_12
https://artifactory.mycompany.com/artifactory/myrepo/abc-2-xyz/ver_3
https://artifactory.mycompany.com/artifactory/myrepo/abc-2-xyz/ver_5
I could see the below stackoverflow question and able to get that working for that use case but unable to construct the AQL for my use case so that i can have the spec file accordingly that can be used to delete what i need here.
Artifactory delete all artifacts older than 6 months
Any help here to help me get the AQL file constructed and then the spec file that can be called for actual deletion, would be greatly appreciated as always.
The following file spec does what you're looking for:
{
"files": [
{
"aql": {
"items.find": {
"repo": "myrepo",
"path": {"$match":"abc-*-xyz"},
"name": {"$match":"ver_*"},
"type": "folder",
"$or": [
{
"$and": [
{
"created": { "$before":"7d" }
}
]
}
]
}
}
}
]
}
The above file spec finds all the folders which match the following criteria:
To delete all the folders found by this file spec, do the following.
jfrog rt del --spec delete-folders-spec