Search code examples
dockermavencurlartifactory

How to list all subdirectories from a Maven repository on Artifactory via cURL?


So I have a docker repository on Artifactory that lists all folders and subfolders from a url with this command:

curl -ksSL -H "X-JFrog-Art-Api:ApiKeyHere" "https://artifactory.service.company:443/artifactory/api/docker/docker-local/v2/_catalog"

The output being:

{ "repositories" : [ "folder1/subfolder1", "folder1/subfolder2", "folder2/subfoler1" ] } and so forth.

However, I've tried and played around with doing this for a Maven repository with this:

curl -kssL -H "X-JFrog-Art-Api:ApiKeyHere" "https://artifactory.service.company:443/artifactory/api/storage/maven-repo/com/company/etc/etc"

But the output is something like:

{
  "repo" : "maven-repo",
  "path" : "/com/company/etc/etc",
  "created" : "2019-05-21T01:00:37.173+10:00",
  "createdBy" : "admin",
  "lastModified" : "2019-05-21T01:00:37.173+10:00",
  "modifiedBy" : "admin",
  "lastUpdated" : "2019-05-21T01:00:37.173+10:00",
  "children" : [ {
    "uri" : "/folder1",
    "folder" : true
  }, {
    "uri" : "/foler2",
    "folder" : true
  }, {
    "uri" : "/folder3",
    "folder" : true
  } ], "uri" : "https://artifactory.service.company/artifactory/api/storage/maven-repo/com/company/etc/etc"
}

As can be seen this command only returns folders 1 level deeper than what is curled versus the one for the Docker repo which lists every single folder and its subfolders. If I try to add some form of /_catalog to the Maven curl command similar to the command for the Docker repo it returns a 404. Was just wondering if there was a way to have the output similar to the Docker command?


Solution

  • Look into the Artifactory List Files REST API call. I think this answers your requirement.

    It has many parameters that can help you control the output. Combined with jq, you have a great tool for listing.

    Another option is the JFrog CLI, which has a Search Files option.