How to find artifacts from Artifactory that have a specific property value using REST API

1.9k views Asked by At

I want to search for all the artifacts in Artifactory that have some property field:

items.find({"@some_property" : {"$eq" : "some_value"}})

How can I do it using a REST API?

3

There are 3 answers

2
Vinny at AppCafe.com On BEST ANSWER

Here is an example:

Following AQL query

items.find(
 {
 "repo":{"$eq":"mymavenrepo"},
 "name": {"$match" : "*.jar"}
 }
)

can be translated to this REST call

http://localhost/artifactory/api/search/artifact?name=*jar&re
pos=jcenter-cache
0
yahavi On

Easier with JFrog CLI:

jfrog rt s '*' --props some_property=some_value

Example results:

[Info] Searching artifacts...
[Info] Found 1 artifact.
[
  {
    "path": "generic-local/hello",
    "type": "file",
    "size": 6,
    "created": "2020-11-29T14:00:18.410Z",
    "modified": "2020-11-29T14:00:18.222Z",
    "sha1": "f572d396fae9206628714fb2ce00f72e94f2258f",
    "md5": "b1946ac92492d2347c6235b4d2611184",
    "props": {
      "some_property": [
        "some_value"
      ]
    }
  }
]
0
Dror Bereznitsky On

You can use the AQL REST API method, for example:

curl -uuser:password -H "content-type: text/plain" -XPOST http://localhost:8081/artifactory/api/search/aql -d "items.find({\"@foo\" : {\"\$eq\" : \"bar\"}})"