Reputation: 11
By using AQL query and Jfrog CLI, we are planning to find out the expired artifacts in our artifactory enterprise version.
For that I would like to pass a variable in AQL Json file to delete the artifacts by using Jfrog CLI.
Because the value of the variable will not be a static value and it will dynamic. So I need to pass a variable into Json file and the below highlighted variable I need to use.
Command:
./jfrog rt del --spec /xxxxxxxx.json --dry-run=true --quiet=true
xxxx.Json:
{
"files":[
{
"aql":{
"items.find":{
"type":"file",
"$or":[
{
"$and":[
{
"stat.downloads":{
"$eq":null
}
},
{
"modified":{
"$before":"1s"
}
},
{
"@retention.RetDate":{
"$lt":"$RetDate"
}
}
]
},
{
"$and":[
{
"stat.downloads":{
"$gt":"0"
}
},
{
"stat.downloaded":{
"$before":"1s"
}
},
{
"modified":{
"$before":"1s"
}
},
{
"@retention.RetDate":{
"$lt":"$RetDate"
}
}
]
}
]
}
}
}
]
}
Upvotes: 1
Views: 1226
Reputation: 1726
If you want variables in your spec file, you should define the variables in the call:
./jfrog rt del --spec /xxxxxxxx.json --spec-vars "RetDate=2018-01-01" --dry-run=true --quiet=true
And unless I am mistaken, the variables are identified as ${key} in the spec file, so something like
[...]
{
"@retention.RetDate":{
"$lt":"${RetDate}"
}
}
[...]
Does it help your test case?
Upvotes: 2