Jenkins Artifactory 插件——获取最新的工件

Jenkins Artifactory plugin - grabbing latest artifacts

我正在尝试保存构建工件并通过 Jenkins Artifactory 插件的 upload/download 规范部分将它们拉入新构建。 有没有办法获取 "latest" 构建工件?

我在 Artifactory file spec docs 中看到下载规范中应该有一个 "build" 元素,我可以在其中指定 "LATEST" 但这不起作用,只是说 "LATEST" 没有找到。也许我一开始就没有正确地将我的构建发布到 Artifactory?

根据 this SO question and this GitHub page,似乎只有 jfrog CLI 支持按日期排序和获取最新的,而 Jenkins 不支持。其他人告诉我,可以使用名称 setter、版本号、描述 [​​=27=] 插件来实现这种功能......但这看起来真的很老套。

我们正在使用 Jenkins 2.60.3 和 Artifactory Enterprise 5.4.5。

如果我使用 "aql",我根本无法使它工作,但在使用 "pattern" 查找文件时它可以工作。当指定 "build" 时,它将仅获取该构建的工件,即使您指向的回购有一堆类似命名的文件(我猜 Artifactory 中的构建元数据会处理这个问题)。如果不指定 "build",它将获取所有匹配的工件。

"build" 应采用 build-name/build-number 格式,但您可以省略数字或使用 LATEST 以获取最新的 successful build's artifacts (我通过创建一个失败的构建来测试它)。

举例说明:
- 这会将文件 3 下载到 Dependencies/file3
- 删除“/LATEST”也将只下载 file3
- 删除整个 "build" 行将下载所有 3 个文件

# Artifactory Repo: example-repo/  
# BuildName: example-build
#   example-repo/file1  (from build 1)   
#   example-repo/file2  (from build 2)   
#   example-repo/file3  (from build 3)

Download File Spec:
{
    "files": [
        {
            "pattern": "example-repo/file*",
            "target": "Dependencies/",
            "recursive": "false",
            "flat" : "true",
            "build" : "example-build/LATEST"
        }
    ]
 }

有关详细信息,请参阅 JFrog 文件规范文档中的 build 关键字 https://www.jfrog.com/confluence/display/RTF/Using+File+Specs

build [Optional]

If specified, only artifacts of the specified build are downloaded. The 'pattern' property is still taken into account when 'build' is specified. The property format is build-name/build-number. If the build number is not specified, or the keyword LATEST is used for the build number, then the latest published build number is used.