Search code examples
artifactoryjfrog-cliartifactory-query-lang

How can I download files from a folder in Artifactory with a specific property using JFrog CLI?


Using JFrog CLI (v1.48.1) I want to download the contents of a folder from an on-premise Artifactory instance (EnterpriseX license 7.41.7). The folder in question is on a specific sub-path in the Artifactory repo and has a specific property by which I can identify the folder.

The overall repo structure is a follows:

product-repo
    |-- develop
    `-- releases
            |-- ProductX
            `-- ProductY
                   |-- build01 [@release_ready = false]
                   |-- build02 [@release_ready = false]
                   `-- build03 [@release_ready = true]
                          |-- x86
                          |    `-- program.exe
                          |-- x64
                          |    `-- program64.exe
                          `-- common
                               `-- README.txt

All buildXX folders are identical in terms of content. All buildXX folders have a property named release_ready which is true for build03 and false for the other two folders.

In the example above, I want to download the folder build03 including all its contents because this folder is on the releases/ProductY path of the product-repo repository and has release_ready = true.

I have devised a file spec for this task:

{
  "files": [
    {
      "aql": {
        "items.find": {
          "repo": "product-repo",
          "path": {"$match":"*releases/ProductY*"},
          "type": "folder",
          "@release_ready": {"$eq": "True"}
        }
      },
      "recursive": "true",
      "target": "some/folder/on/my/disk/"
    }
  ]
}

Using JFrog CLI to search this folder (jfrog rt s --spec myfilespec.json) works like a charm - as expected, Jfrog returns the folder build03.

However, when I try to download the folder using jfrog rt dl --spec myfilespec.json Jfrog CLI only creates the folder structure releases/ProductY/build03 at the target path but never actually downloads any files. The exact log output is as follows:

 Log path: C:\Users\myuser\.jfrog\logs\jfrog-cli.<date>.log
{
  "status": "success",
  "totals": {
    "success": 0,
    "failure": 0
  }
}

With the log file containing just the following lines:

[Info] Searching items to download...
[Info] [Thread 2] Downloading procduct-repo/repeases/ProgramY/build03/
[Info] [Thread 2] Creating folder: releases\ProgramY\build03

What am I missing?


Solution

  • So, from above explanation, it gives a clarification that you have the property and value applied on a the folder only but not on the artifacts under it. Your first AQL query results only the folder name. Since it reveles the folder name, would it be feasible to pass the above result in the download command as below.

    jfrog rt dl "product-repo/releases/ProductY/build3/*" --flat=false /some/folder/on/my/disk/