简体   繁体   English

Jenkins Artifactory 插件 - 抓取最新的工件

[英]Jenkins Artifactory plugin - grabbing latest artifacts

I am trying to save build artifacts and pull them into new builds via the upload/download spec portion of the Jenkins Artifactory plugin.我正在尝试通过 Jenkins Artifactory 插件的上传/下载规范部分保存构建工件并将它们拉入新构建中。 Is there a way to grab the "latest" build artifacts?有没有办法获取“最新”的构建工件?

I see in the Artifactory file spec docs that there should be a "build" element in the download spec where I can specify "LATEST" but that doesn't work, just says "LATEST" not found.我在Artifactory 文件规范文档中看到,下载规范中应该有一个“构建”元素,我可以在其中指定“最新”,但这不起作用,只是说找不到“最新”。 Maybe I am not publishing my builds to Artifactory correctly in the first place?也许我一开始就没有正确地将我的构建发布到 Artifactory?

According to this SO question and this GitHub page it appears that sorting by date and grabbing the newest is only supported with the jfrog CLI and not in Jenkins.根据this SO questionthis GitHub page ,似乎只有jfrog CLI才支持按日期排序并获取最新信息,而Jenkins不支持。 Others told me that this sort of functionality can be had using the name setter, version number, description setter plugings... but that seems really hacky.其他人告诉我,可以使用名称设置器、版本号、描述设置器插件来实现这种功能……但这似乎真的很糟糕。

We are using Jenkins 2.60.3 and Artifactory Enterprise 5.4.5.我们使用 Jenkins 2.60.3 和 Artifactory Enterprise 5.4.5。

I could not get this to work at all if I was using "aql", but it works when using "pattern" to find the file(s).如果我使用“aql”,我根本无法使其正常工作,但是在使用“模式”查找文件时它可以工作。 When "build" is specified it will grab that build's artifacts only, even if the repo you're pointing at has a bunch a similarly named files (the build metadata in Artifactory takes care of this I guess).当指定“build”时,它只会抓取该构建的工件,即使您指向的存储库有一堆名称相似的文件(我猜,Artifactory 中的构建元数据会处理这个问题)。 Without specifying "build" it would grab all of the matching artifacts.如果不指定“build”,它将获取所有匹配的工件。

"build" should be in the build-name/build-number format, but you can leave off the number OR use LATEST in order to grab the latest successful build's artifacts (I tested this by creating a failed build). “build”应该是 build-name/build-number 格式,但你可以省略数字或使用 LATEST 来获取最新的成功构建的工件(我通过创建一个失败的构建来测试这个)。

Example to illustrate:举例说明:
- This will download file3 to Dependencies/file3 - 这会将 file3 下载到 Dependencies/file3
- Removing "/LATEST" will also download only file3 - 删除“/LATEST”也将只下载文件 3
- Removing the whole "build" line will download all 3 files - 删除整个“构建”行将下载所有 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"
        }
    ]
 }

For more info, see the build keyword in JFrog File Specs document https://www.jfrog.com/confluence/display/RTF/Using+File+Specs有关更多信息,请参阅 JFrog 文件规范文档https://www.jfrog.com/confluence/display/RTF/Using+File+Specs 中build关键字

build [Optional]构建 [可选]

If specified, only artifacts of the specified build are downloaded.如果指定,则仅下载指定构建的工件。 The 'pattern' property is still taken into account when 'build' is specified.指定 'build' 时,仍会考虑 'pattern' 属性。 The property format is build-name/build-number.属性格式为 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.如果未指定内部版本号,或关键字 LATEST 用于内部版本号,则使用最新发布的内部版本号。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM