Artifactory aql: find builds of job with given property

南楼画角 提交于 2019-11-29 16:50:38

Here's a working solution that will give build numbers (since giving admin rights to query builds is not a solution for us):

query.json:

items.find(
{
  "repo":"snapshot-local",
  "artifact.module.build.name":"foo",
  "artifact.item.@vcs.Revision":"aabbccddee123456"
}
).include("artifact.module.build.number")

This returns a list of all the artifacts that were built with the relevant properties, with the build number attached, e.g:

{
"results" : [ {
  "repo" : "snapshot-local",
  "path" : "foo/42",
  "name" : "a.out",
  "type" : "file",
  "size" : 123456789,
  "created" : "2018-07-05T12:34:56.789+09:00",
  "created_by" : "jenkins",
  "modified" : "2018-07-05T12:34:56.789+09:00",
  "modified_by" : "jenkins",
  "updated" : "2018-07-05T12:34:56.789+09:00",
  "artifacts" : [ {
    "modules" : [ {
      "builds" : [ {
        "build.number" : "42"
      } ]
    } ]
  } ]
},
[SNIP]
}
 ],
"range" : {
  "start_pos" : 0,
  "end_pos" : 30,
  "total" : 30
}
}

I can then parse this to extract build.number.

Certain AQL queries requires a user with admin permissions. To ensure that non-privileged users do not gain access to information without the right permissions, users without admin privileges have the following restrictions:

  1. The primary domain in the query may only be item.
  2. The following three fields must be included in the include directive: name, repo, and path.

In your case, you are using the build domain in the query which requires admin permissions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!