I am trying to delete artifacts ( older than 6 months) from a list of repositories in jfrog artifactory. I am creating a spec file like below and using that spec i am deleting using jfrog cli. My query is there any way i can execute the aql in loops instead of manually updating the repo name: foobar
{
"files": [
{
"aql": {
"items.find": {
"repo": "foobar",
"$or": [
{
"$and": [
{
"modified": { "$lt": "2021-06-06T21:26:52.000Z"}
}
]
}
]
}
}
}
]
}```
jfrog rt del --spec /tmp/foo.spec --dry-run
I want to run the aql in loops only change will be the repo name . Is there a way to do it ?
Looks like we don't have a direct way to achieve this, but you can make use of -spec-vars in order to pass dynamic variables through jf
CLI command. You can write a script to pass names of selected repositories in a loop and use --spec-vars as follows:
jf rt del --spec test.spec --spec-vars "RepoKey=libs-release-local" --dry-run
and spec file will look like this:
{
"files": [
{
"aql": {
"items.find": {
"repo": "${RepoKey}",
...............
}
}
}
]
}
Also, there is an Artifactory Cleanup User Plugin where you can specify required repositories names to be cleaned up as per your needs, so you may check this one too.