Resolution

How to do time-stamping downloads with the JFrog CLI

AuthorFullName__c
JFrog Support
articleNumber
000004133
ft:sourceType
Salesforce
FirstPublishedDate
2018-05-25T00:02:27Z
lastModifiedDate
2022-04-11
VersionNumber
5
We may for example create a bash script, which we named tmstpDownload.sh in this case, and add the following one-line script which calls the JFrog CLI (make sure the CLI is in one of the directories in your $PATH, or otherwise adapt the script to pick up the CLI file.):
jfrog rt dl --spec=$3 --spec-vars="time_stamp=$(find $2 -printf "20%Ay-%Am-%Ad" || printf 0);repo="$1";name="$2""
This script takes 3 arguments, referenced in the code as $1, $2, and $3.
$ tmstpDownload.sh <repo name> <artifact name> <spec template>

The first one you see is a "spec template", which is a file spec adapted to take variables from the script. Being that you could adapt this script for as many tasks as you can think of, we decided to make the spec file, as well as the repo and file name, arguments of the script. You may hard code a path if you like, and as long as you have the
{"created":{"$gt":"${time_stamp}"} 
part in your AQL it will work, but having both the name and repo as arguments will allow you to flexibly use wildcards for your downloads.

The second argument is the name of the file, and as we mentioned it is passed to the Spec File as a variable. The script also uses this file name to find the timestamp of a local file and find a possible download.
A more efficient way could be to adapt the script to look for the checksum of the present files and search based on that. The AQL fields would be for example "actual_md5", "actual_sha1" or "sha256".
The template is a spec file that takes in variables from the script. In this case, we used the following file which we named template. spec:
{
 "files": [{
     "aql": {
        "items.find" : {
          "repo":"${repo}",
          "$and": [{
              "created":{"$gt":"${time_stamp}"},
              "name": {"$match":"${name}"}
          }]}}}]} 

Being able to choose which template you want to use allows for an incredible amount of flexibility in customization when downloading large numbers of artifacts.