Comparing Files Against Local Store When Downloading From Artifactory

Let’s say you want to download a large amount of files from Artifactory to your local storage. However, you don’t want to download files you already have, or that have been modified more recently locally.

Artifactory, or its tools, don’t have any built-in functionality that will compare your local files’ timestamp to what’s available on your server. However, we can get creative and achieve Timestampped CLI Downlaods

As a workaround we will be using File Specs on download with the JFrog CLI. A combination of using file specs along with Unix/Linux commands can achieve the desired result.

To recap, the requirements are the following:

  • Download the files according to a specific set of requirements
  • Download the file if it doesn’t already exist
  • If the file already exists, only download it if it’s newer than the locally available one

What we are able to do is create a script. For name let’s name it It contains the following one-line script:

If you are not familiar with the CLI, we are essentially telling it to download files according to a Spec File (linked earlier) which will define the artifacts we want and the criteria to meet. The spec-vars flag allows us to pass variables as key-value pairs that can then be replaced inside the spec at run time.

These spec files can work as templates for different situations that are needed, and in general, even outside of this use case, they can be pretty useful to have around.

We can now run the script with the following arguments, referenced in the code as $1, $2, and $3

$ <repo name> <artifact name> <template>

Where template is a spec file, for example in this case we used the following file which we named template.spec:

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. If you want to stick to one template you could also hard code the repo/name/whatever else into the script or use AQL instead of the spec.

Get creative and get downloading!




Python Coder — DevOps Padawan — Total Nerd

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Angello Maggio

Angello Maggio

Python Coder — DevOps Padawan — Total Nerd

More from Medium

How To Install Prometheus On Ubuntu 20.04 With Let’s Encrypt SSL And Authentication

RHEL8 in Virtual Box :)

Installing pfSense on ESXi

Successfully installed VM, ready to install pfSense

Local and Global variables