1. Create a File Spec and use AQL to specify the repo and path to the targeted artifacts. All artifacts under the listed repo/path will be sorted in descending order by their names, and the last 2 artifacts will be excluded. If one looks for all artifacts in multiple folders which share the same directory structure, one can include the depth in the AQL query.
Below is an example:
Please note that the offset value can be changed if you are looking to exclude more versions.
2. Run JFrog CLI and pass the File Spec that was created. It will return a list of targeted artifacts that met the requirements:
Below is an example:
{ "files": [ { "aql": { "items.find": { "repo": "$repoName", "path": "path/to/artifacts", "type": "folder" } }, "sortBy": ["name"], "sortOrder": "desc", "offset": 2 } ] }
Please note that the offset value can be changed if you are looking to exclude more versions.
2. Run JFrog CLI and pass the File Spec that was created. It will return a list of targeted artifacts that met the requirements:
jf rt s --spec=fileSpec.json