我正在尝试使用AQL来获取所有未升级到“发布”的构建的列表。
我们的二进制文件通过状态集成-> aat ->发布,我想获得那些具有升级状态、集成和aat但没有发布的列表。
构建的一个示例具有状态:
"statuses" : [ {
"status" : "integration",
"timestamp" : "2016-04-20T08:36:42.009+0000",
"user" : "user",
"ciUser" : "changes",
"timestampDate" : 1461141402009
}, {
"status" : "aat",
"repository" : "repo-aat",
"timestamp" : "2016-04-20T08:56:11.843+0000",
"user" : "user",
"ciUser" : "changes",
"timestampDate" : 1461142571843
}, {
"status" : "aat",
"repository" : "repo-aat",
"timestamp" : "2016-04-20T08:58:55.417+0000",
"user" : "user",
"ciUser" : "changes",
"timestampDate" : 1461142735417
}, {
"status" : "aat",
"repository" : "repo-aat",
"timestamp" : "2016-04-20T09:20:32.619+0000",
"user" : "user",
"ciUser" : "changes",
"timestampDate" : 1461144032619
}, {
"status" : "release",
"repository" : "repo-release",
"timestamp" : "2016-04-20T09:30:12.143+0000",
"user" : "user",
"ciUser" : "changes",
"timestampDate" : 1461144612143
}, {
"status" : "release",
"repository" : "repo-release",
"timestamp" : "2016-04-20T09:40:50.595+0000",
"user" : "admin",
"ciUser" : "changes",
"timestampDate" : 1461145250595
} ],
无论我们是否设置,此构建都是匹配的:
{"promotion.status": {"$nmatch":"aat"}}
至
{"promotion.status": {"$nmatch":"release"}}
{"promotion.status": {"$nmatch":"integration"}}
使用该请求:
builds.find({
"$and" : [
{"name": {"$match": "test"}},
{"created": {"$lt": "2016-12-01"}},
{"promotion.status": {"$nmatch":"release"}}
]
}).include("promotion.status").limit(10)
我们得到这样的响应:
{
"results" : [ {
"build.created" : "2016-04-20T10:12:46.905Z",
"build.created_by" : "test",
"build.modified" : "2016-04-20T11:45:12.309Z",
"build.modified_by" : "admin",
"build.name" : "user",
"build.number" : "2551",
"build.promotions" : [ {
"build.promotion.status" : "aat"
}, {
"build.promotion.status" : "integration"
} ],
"build.url" : "URL"
} ],
"range" : {
"start_pos" : 0,
"end_pos" : 1,
"total" : 1,
"limit" : 10
}
发布于 2017-01-05 04:18:20
如果您不需要在$nmatch
中使用通配符,则可以改用$ne
,例如:
builds.find({
"$and" : [
{"name": {"$match": "test"}},
{"created": {"$lt": "2016-12-01"}},
{"promotion.status": {"$ne":"release"}}
]
}).include("promotion.status").limit(10)
使用$nmatch
时,也可以使用以下功能:
builds.find({
"$and" : [
{"name": {"$match": "test"}},
{"created": {"$lt": "2016-12-01"}},
{"promotion.status": {"$nmatch":"releas*"}}
]
}).include("promotion.status").limit(10)
发布于 2019-05-24 04:00:17
您要做的是,向Artifactory询问构建的“最新”状态,并根据该状态进行过滤。然而,这不是Artifactory处理AQL查询的方式。
请注意,您的构建没有"build.promotion.status“属性。相反,您的构建具有名为"build.promotions“的数组类型的属性。在此数组中,可以为您的构建设置任意数量的升级历史记录项,包括属性"build.promotion.status“。
现在假设您的AQL查询将选择具有"build.promotion.status“:"aat”的构建,您真正要求Artifactory的是这样的:请返回build.promotions数组的任何元素都具有匹配属性"build.promotion.status“:"aat”的任何构建。
因此,即使你的例子中的build #2551已经从"aat“升级到"released",你还是在询问AQL是否在任何时候都有升级状态"aat",它确实有。
更令人困惑的是,当您包含(“promotion.status”)时,您将看到促销历史记录项的过滤子集。
如果你试图通过问相反的问题来解决这个问题:哪些构建没有任何带有"build.promotion.status“= "released”的构建状态历史记录项,即使这在AQL中是可能的,它也不会告诉你当前的状态是什么。如果你的构建曾经是“回滚”的,它也不会正常工作。
我认为JFROG实际上应该引入一个"build.promotion.status“字段,它做了人们合理期望的事情:为您提供当前状态以供显示和查询。在此之前,我能想到的唯一解决方案就是获取所有的构建升级项,然后用更高级的语言来施展魔法。
https://stackoverflow.com/questions/41465375
复制相似问题