I am trying to query which build number(s) produced artifacts from build foo
with artifact property vcs.Revision=aabbccddee123456
.
我试图通过工件属性vcs.Revision = aabbccddee123456查询哪些构建号从build foo生成工件。
In Artifactory 5.1.3.
在Artifactory 5.1.3中。
I was trying like this so far:
到目前为止我这样做是这样的:
curl -u user:apikey -i -X POST https://artifactory.foobar.com/artifactory/api/search/aql -H "content-type:text/plain" -T query.json
curl -u user:apikey -i -X POST https://artifactory.foobar.com/artifactory/api/search/aql -H“content-type:text / plain”-T query.json
query.json:
query.json:
builds.find(
{
"module.artifact.item.repo":"snapshot-local",
"name":"foo",
"module.artifact.item.@vcs.Revision":"aabbccddee123456"
}
)
However, none of these 3 lines seem individually correct:
但是,这3行中没有一行看起来是正确的:
-
builds.find({"module.artifact.item.repo":"snapshot-local"})
returns nothing,builds.find({“module.artifact.item.repo”:“snapshot-local”})什么都不返回,
-
builds.find({"name":"foo"})
returns the same empty response,builds.find({“name”:“foo”})返回相同的空响应,
-
builds.find({"module.artifact.item.@vcs.Revision":"aabbccddee123456"})
also returns this:builds.find({“module.artifact.item。@ vcs.Revision”:“aabbccddee123456”})也返回:
{ "results" : [ ], "range" : { "start_pos" : 0, "end_pos" : 0, "total" : 0 } }
{“results”:[],“range”:{“start_pos”:0,“end_pos”:0,“total”:0}}
What am I doing wrong here? I do see in the webapp the builds I published with this name, and with the correct artifact properties.
我在这做错了什么?我确实在webapp中看到了我用这个名字发布的版本,以及正确的工件属性。
2 个解决方案
#1
1
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
:
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
.
然后我可以解析它来提取build.number。
#2
0
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:
某些AQL查询要求具有管理员权限的用户。为确保非特权用户在没有正确权限的情况下无法访问信息,没有管理员权限的用户具有以下限制:
- The primary domain in the query may only be item.
- 查询中的主域可能只是项目。
- The following three fields must be included in the include directive: name, repo, and path.
- include指令中必须包含以下三个字段:name,repo和path。
In your case, you are using the build domain in the query which requires admin permissions
在您的情况下,您在查询中使用构建域,该域需要管理员权限
#1
1
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
:
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
.
然后我可以解析它来提取build.number。
#2
0
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:
某些AQL查询要求具有管理员权限的用户。为确保非特权用户在没有正确权限的情况下无法访问信息,没有管理员权限的用户具有以下限制:
- The primary domain in the query may only be item.
- 查询中的主域可能只是项目。
- The following three fields must be included in the include directive: name, repo, and path.
- include指令中必须包含以下三个字段:name,repo和path。
In your case, you are using the build domain in the query which requires admin permissions
在您的情况下,您在查询中使用构建域,该域需要管理员权限