将文件从 Artifactory 下载到 Teamcity 而不保留其完整路径 [英] Download files from Artifactory to Teamcity without retaining their full path

查看:36
本文介绍了将文件从 Artifactory 下载到 Teamcity 而不保留其完整路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用

  • TeamCity Enterprise 2017.1.2(内部版本 46812)
  • Artifactory Professional 5.3.1 修订版 50046
  • Teamcity 已安装 Artifactory 插件(2.3.0 版)

任务很简单 - 从 Artifactory 下载文件到 Teamcity build:

The task is simple - download files from Artifactory to Teamcity build:

  • 来自 Artifactory MyRepo/RootFolder/ProjectFolder/1.2.3/
  • 到 TC %checkoutdir%/artifacts/

路径的 部分包含文件夹和文件,我想保留它们的结构.

The <files> part of the path contains both folders and files and I want to retain their structure.

下载规范json是:

{
  "files": [
    {
      "pattern": "MyRepo/RootFolder/ProjectFolder/1.2.3/",
      "target": "artifacts/"
    }
  ]
}

<小时>

但是,文件下载到的位置与我预期的不同:


However, the files get downloaded into a different location than I would expect:

  • 实际:artifacts/RootFolder/ProjectFolder/1.2.3/
  • 预期:artifacts/

Artifactory 的整个路径附加在目标目录之后.我如何告诉插件只使用指定根目录之后的文件的相对路径?我试过摆弄通配符、斜线等,但没有任何帮助.

The whole path from Artifactory gets appended after the target directory. How do I tell the plugin to only use the relative path of files after the specified root? I have tried fiddling about with wildcards, slashes etc, but nothing helped.

我必须创建一个额外的构建步骤,在其中手动将文件移动到我期望的结构,但我不想这样做.

I had to create an extra build step where I manually move files to the structure I expect, but I would prefer not to have to do that.

工作答案:

{
  "files": [
    {
      "pattern": "MyRepo/RootFolder/ProjectFolder/1.2.3/(*)",
      "target": "artifacts/{1}",
      "flat": "true"
    }
  ]
}

<小时>

推荐答案

您可以按照 此处.占位符允许您捕获文件规范模式"属性值的特定部分,并在目标"属性值中使用它.

You can customize your target structure by using Placeholders in your File Specs as described here. Placeholders allow you to capture a specific section of your File Spec "pattern" property value, and use it inside the "target" property value.

在您的情况下,下载文件规范应如下所示:

In your case, the download File Spec should look like this:

{
  "files": [
    {
      "pattern": "MyRepo/RootFolder/ProjectFolder/1.2.3/(*)",
      "target": "artifacts/{1}"
    }
  ]
}

这篇关于将文件从 Artifactory 下载到 Teamcity 而不保留其完整路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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