AQL Artifactory:找到具有给定属性的工作机会 [英] 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"
}
)
但是,这三行似乎都不正确:
However, none of these 3 lines seem individually correct:
-
builds.find({"module.artifact.item.repo":"snapshot-local"})
不返回任何内容,
builds.find({"name":"foo"})
返回相同的空响应,
builds.find({"name":"foo"})
returns the same empty response,
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
}
}
我在这里做错了什么?我确实在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
.
这篇关于AQL Artifactory:找到具有给定属性的工作机会的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!