Artifactory aql:查找具有给定属性的工作构建 [英] Artifactory aql: find builds of job with given property
问题描述
我正在尝试通过构件属性 vcs.Revision=aabbccddee123456
查询从构建 foo
生成的构件.
I am trying to query which build number(s) produced artifacts from build foo
with artifact property vcs.Revision=aabbccddee123456
.
在 Artifactory 5.1.3 中.
In 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
query.json:
query.json:
builds.find(
{
"module.artifact.item.repo":"snapshot-local",
"name":"foo",
"module.artifact.item.@vcs.Revision":"aabbccddee123456"
}
)
然而,这 3 行似乎都不正确:
However, none of these 3 lines seem individually correct:
builds.find({"module.artifact.item.repo":"snapshot-local"})
什么都不返回,
builds.find({"name":"foo"})
返回相同的空响应,
builds.find({"module.artifact.item.@vcs.Revision":"aabbccddee123456"})
也返回这个:
<代码>{结果" : [ ],范围" : {开始位置":0,end_pos":0,总计":0}}
我在这里做错了什么?我确实在 webapp 中看到了我用这个名称发布的构建,以及正确的工件属性.
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.
推荐答案
这是一个提供内部版本号的可行解决方案(因为授予查询内部版本的管理员权限不是我们的解决方案):
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
}
}
然后我可以解析它以提取build.number
.
I can then parse this to extract build.number
.
这篇关于Artifactory aql:查找具有给定属性的工作构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!