AQL build domain object does not return results
Asked Answered
S

1

6

I'm running into an issue where I'm not able to get any of the queries I'm making on the build domain object to return when using AQL

When I make the following curl:

curl -X GET -H "X-JFrog-Art-Api: myArtifactroyKey" -H "Cache-Control: no-cache" "https://MyArtifactoryServer/artifactory/api/build/"

I get a set of results:

{
  "builds": [
    {
      "uri": "/someBuild",
      "lastStarted": "2017-02-15T22:02:49.066+0000"
    },
    {
      "uri": "/someOtherBuild",
      "lastStarted": "2017-02-15T21:45:09.590+0000"
    }, 
      "uri": "/someThirdBuild",
      "lastStarted": "2017-02-15T21:17:38.794+0000"
    }
],
  "uri": "https://myArtifactoryServer/artifactory/api/build"
}

so I know that there are builds in my Artifactory

however, when I make the following curl, which I believe to be requesting all builds with any name, I get no results

curl -X POST -H "X-JFrog-Art-Api: myArtifactroyKey" -H "Content-Type: application/x-www-form-urlencoded" -H "Cache-Control: no-cache" -d 'builds.find({"name": {"$match":"*"}})' "https://MyArtifactoryServer/artifactory/api/search/aql"

returns:

{
  "results": [],
  "range": {
    "start_pos": 0,
    "end_pos": 0,
    "total": 0
  }
}

I've been able to get results when using items.find() but have not had any luck with builds.find() Is there something that I'm missing?

My overall intention is to have a Query that returns the most recent build information of a specific build based on the name but I have been unable to get even the most simple of Query against the build domain object to work.

Thanks in advance for the help.

Simsar answered 15/2, 2017 at 23:24 Comment(2)
I tried running your query (changing the API key and MyArtifactoryServer) and it worked like a charm. Can you check the request.log in Artifactory and share the log line related to this query? Also, are you using an admin user? if not can you try an admin user and see if something changes?Skeen
Workaround solution can be found at #51175939Leah
G
5

The answer might be related to permissions. If the API key you are using belong to a non admin user than it can explain the situation.
Querying the build domain using AQL requires admin permissions, while the "All Builds" API only requires a privileged user.

Groos answered 17/2, 2017 at 22:25 Comment(3)
I found that the above query would only work if the user had "Admin" privileges. I can understand that that the query would require a privileged user, but am surprised that it requires the highest level of privilege. Could that be right? Is there a different way to get the same information w/o requiring such a powerful privilege setting?Bogoch
With regards to the AQL query this is the current situation. Some of the AQL domains are limited for admin access only.Groos
Defective that /api/search/aql API doesn't make this clear by returning the appropriate HTTP error status when the user has insufficient privilege (403 Forbidden would be appropriate here); Bizarre that a (preumably heavier) fetch-all /api/build is allowed whilst a narrower AQL query is not; And frustrating that /api/build does not itself support any filtering.Leah

© 2022 - 2024 — McMap. All rights reserved.