Jenkins Artifactory 插件 - 抓取最新的工件 [英] Jenkins Artifactory plugin - grabbing latest artifacts

查看:81
本文介绍了Jenkins Artifactory 插件 - 抓取最新的工件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试保存构建工件并通过 Jenkins Artifactory 插件的上传/下载规范部分将它们拉入新构建.有没有办法获取最新的"构建工件?

I am trying to save build artifacts and pull them into new builds via the upload/download spec portion of the Jenkins Artifactory plugin. Is there a way to grab the "latest" build artifacts?

我在 Artifactory 文件规范文档中看到有应该是下载规范中的构建"元素,我可以在其中指定最新",但这不起作用,只是说找不到最新".也许我一开始就没有正确地将我的构建发布到 Artifactory?

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. Maybe I am not publishing my builds to Artifactory correctly in the first place?

根据这个SO问题这个 GitHub 页面 看来按日期排序和抓取最新的只支持 jfrog CLI 而不是 Jenkins.其他人告诉我,可以使用名称设置器、版本号、描述设置器插件来实现此类功能……但这似乎真的很糟糕.

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. 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.

我们使用的是 Jenkins 2.60.3 和 Artifactory Enterprise 5.4.5.

We are using Jenkins 2.60.3 and Artifactory Enterprise 5.4.5.

推荐答案

如果我使用aql",我根本无法使其正常工作,但是在使用模式"查找文件时它可以工作.当指定build"时,它只会抓取该构建的工件,即使您指向的存储库有一堆名称相似的文件(我猜,Artifactory 中的构建元数据会处理这个问题).如果不指定build",它将获取所有匹配的工件.

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). 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). Without specifying "build" it would grab all of the matching artifacts.

"build" 应该是 build-name/build-number 格式,但你可以省略数字或使用 LATEST 来获取最新的 successful 构建的工件(我测试了这个创建失败的构建).

"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).

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

Example to illustrate:
- This will download file3 to Dependencies/file3
- Removing "/LATEST" will also download only file3
- Removing the whole "build" line will download all 3 files

# 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/使用+文件+规范

For more info, see the build keyword in JFrog File Specs document https://www.jfrog.com/confluence/display/RTF/Using+File+Specs

构建[可选]

如果指定,则只有指定构建的工件被下载.'pattern' 属性仍然被考虑在内当'build'被指定时.属性格式为构建名称/构建编号.如果未指定内部版本号,或者关键字 LATEST 用于内部版本号,然后是最新发布的使用内部版本号.

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.

这篇关于Jenkins Artifactory 插件 - 抓取最新的工件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆