简体   繁体   English

使用Jenkins中的Artifactory插件有条件地从工件下载文件

[英]Use the Artifactory Plugin in Jenkins to conditionally download files from artifactory

How can I choose a different download spec for the Jenkins Artifactory plugin based on the value of a build job string parameter? 如何根据构建作业字符串参数的值为Jenkins Artifactory插件选择其他下载规范?

For a given value of the string parameter I want to download a folder from artifactory, and for a different value of the string parameter I want to download a different folder from artifactory. 对于给定的字符串参数值,我想从人工制品中下载文件夹,对于不同的字符串参数值,我想从人工制品中下载另一个文件夹。

I'm trying to get these folders directly from artifactory because they contain build output from a different project that my build needs to use and change frequently, I can't just check them into the SCM for my build, but must have the current versions at build time. 我试图直接从人工制品中获取这些文件夹,因为它们包含来自我的构建需要经常使用和更改的不同项目的构建输出,我不能只是将它们检入SCM以进行构建,而是必须具有当前版本在构建时。

I've looked at the pages for the Jenkins Artifactory Plugin and at the Jfrog Artifactory user guide but I haven't found anything on how to do this using the plugin. 我查看了Jenkins Artifactory插件的页面和Jfrog Artifactory用户指南,但是我没有找到有关如何使用该插件执行此操作的任何信息。

I'm using a freestyle build with the Generic-Artifactory Integration option. 我正在使用带有通用人工集成选项的自由式构建。

Jenkins version: 1.651.3 詹金斯版本:1.651.3
Artifactory Plugin Version: 2.8.1 Artifactory插件版本:2.8.1
Artifactory Version 4.6.1 Artifactory版本4.6.1

You can use environment variables in both the spec path and the spec content. 您可以在规范路径和规范内容中使用环境变量。

In your case, you can upload to your SCM a spec for each job with the job name in the path. 对于您自己的情况,您可以将每个作业的规范上载到路径中,并将其上传到SCM。 Then, you can dynamically set the spec file path using environment variable as shown below: 然后,您可以使用环境变量动态设置规格文件路径,如下所示: specFilePath

Another way is to set a variable (for example PATTERN-PATH) in each job and use it in the spec. 另一种方法是在每个作业中设置一个变量(例如PATTERN-PATH)并在规范中使用它。

{
  "pattern": "libs-snapshot-local/${PATTERN-PATH}/*",
  "target": "out/downloaded/"
}

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

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