yiaca
yiaca

Reputation: 187

How to find specific artifacts using aql and jfrog cli

I want to find all the artifacts that contain specific pattern, except of few.

My aql.json

items.find({
    "name":{"$match": "*test*"},
    "name":{"$nmatch": "*test1*"},
    "name":{"$nmatch": "*test2*"}
   })

and I get this error:

[Error] invalid character 'i' looking for beginning of value

My jfrog cli cmd:

jfrog rt s --spec=aql.json

(I alredy config my artifactory with admin user on my linux env)

EDIT aql.json

{
    "files" :  [
        {
            "aql" : {
                "items.find" :{
                    "repo": "myRepo",
                    "path" : {"$match": "*/somedir/somedir*"},
                    "$and" : 
                    [
                        {"name" : {"$match" : "*test*"}},
                        {"name" : {"$nmatch" : "*test1*"}},
                        {"name" : {"$nmatch" : "*test2*"}}

                    ]

                }
            }
        } 
    ]
}

But it didn't find my artifacts (and I have artifacts that match this pattern.

[Info] Found 0 artifacts.
[]

Upvotes: 3

Views: 4452

Answers (1)

yahavi
yahavi

Reputation: 6033

It expects to get a JSON. This one worked for me:

{
  "files": [
    {
      "aql": {
        "items.find": {
          "$and": [
            { "name": { "$match": "*test*" } },
            { "name": { "$nmatch": "*test_1*" } },
            { "name": { "$nmatch": "*test_2*" } }
          ]
        }
      }
    }
  ]
}

Upvotes: 5

Related Questions