简体   繁体   中英

Download files from Artifactory to Teamcity without retaining their full path

I am using

  • TeamCity Enterprise 2017.1.2 (build 46812)
  • Artifactory Professional 5.3.1 rev 50046
  • Teamcity has the Artifactory plug-in installed (ver 2.3.0)

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

  • From Artifactory MyRepo/RootFolder/ProjectFolder/1.2.3/<files>
  • To TC %checkoutdir%/artifacts/<files>

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

The download spec json is:

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

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

  • Actual: artifacts/RootFolder/ProjectFolder/1.2.3/<files>
  • Expected: artifacts/<files>

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.


WORKING ANSWER:

{
  "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}"
    }
  ]
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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