【发布时间】:2017-02-21 18:14:33
【问题描述】:
我正在将链接到管道中的现有 Jenkins 作业系列移动到现代 Jenkins 即代码工作流管道。
随着这一举措而来的是各种新插件,它们提供了 Pipeline 插件可以使用的步骤。其中之一是 Jenkins Artifactory 插件。
这个插件可以接受 Artifactorys “AQL” 语言的 json 对象,或者相反,一个非常简单的模式来搜索一系列 repos 以查找与模式匹配的 Artifacts。
我尝试使用“AQL”和模式来解决我的工件。
我遇到的问题是,我想模仿可以在 Jenkins Jobs 中使用的现有 Jenkins Artifact Resolver 插件的行为。
此插件使用我当前提供给 DSL 工作流的相同模式,并且仅下载该特定返回集中的最新或最后修改的工件。我想为我的新方法做同样的事情。
这是使用基于模式的搜索的结果:
jfrog rt search "client-snapshots/com/client/content_services/search-dist/*.zip"
[Info:] Pinging Artifactory...
[Info:] Done pinging Artifactory.
[Info:] Searching Artifactory using AQL query: items.find({"repo": "client-snapshots","$or": [{"$and": [{"path": {"$match":"com/client/content_services/search-dist"},"name":{"$match":"*.zip"}}]},{"$and": [{"path": {"$match":"com/client/content_services/search-dist/*"},"name":{"$match":"*.zip"}}]}]}).include("name","repo","path","actual_md5","actual_sha1","size")
[Info:] Artifactory response: 200 OK
[Info:] Found 58 artifacts.
这是使用来自精心设计的 json 对象的“AQL”查询的结果
jfrog rt search --spec art-search.json
[Info:] Pinging Artifactory...
[Info:] Done pinging Artifactory.
[Info:] Searching Artifactory using AQL query: items.find({"repo":"client-snapshots","$and":[{"$or":[{"path":{"$match":"com/client/content_services"},"name":{"$match":"*search*"}}]},{"$or":[{"path":{"$match":"*dist*"},"name":{"$match":".zip"}}]},{"$or":[{"path":{"$match":"*1.0-SNAPSHOT*"},"name":{"$match":"*"}}]}]}).include("name","repo","path","actual_md5","actual_sha1","size")
[Info:] Artifactory response: 200 OK
[Info:] Found 116 artifacts.
以及上述查询的 json:
{
"files": [
{
"aql": {
"items.find": {
"repo": "client-snapshots",
"$and": [
{
"$or": [
{
"path": {
"$match": "com/client/content_services"
},
"name": {
"$match": "*search*"
}
}
]
},
{
"$or": [
{
"path": {
"$match": "*dist*"
},
"name": {
"$match": ".zip"
}
}
]
},
{
"$or": [
{
"path": {
"$match": "*1.0-SNAPSHOT*"
},
"name": {
"$match": "*"
}
}
]
}
]
}
},
"target": "Bazinga/Artifactory/"
}
]
}
第一个只返回我指定的 repo 中的 zip,这是我真正想要的。 json 对象从我指定的存储库中返回 poms 和 zip。我可以不用 pom,因为我只对下载 zip 文件感兴趣。
更重要的是,我只想使用上述模式之一返回最新的 zip。
任何建议将不胜感激
【问题讨论】:
标签: json maven jenkins artifactory artifactory-query-lang