Search code examples
azure-devopsazure-pipelinesfile-copying

How to upgrade complex Azure Devops Pipeline Copy BuildArtifact task to Copy PipelineTask?


Yes I know about this: VSTS build Copy Files task copies full path to destination

That issue just describes perfectly how DownloadBuildArtifacts@ is totally not compatible with CopyFiles@ task and subsequent other tasks for publishing. The solutions suggested are perfectly feasible for small pipelines.

I have a set of pipelines (from 2016) with almost a hundred tasks. Works fine with several DownloadBuildArtifact tasks, but that one is deprecated. Each DownloadBuildArtifact task can cover dozens of folders in several layers.

Now the suggestion is to

  1. Multiple Copy Files tasks (using FlattenFolders parameter)

  2. Just deal with the extra directories.

The impact of 1 would be to have to split 1 task that copies a tree into dozens of tasks each handling just 1 folder.

The impact of 2 would be having to amend dozens of subsequent/downline tasks and scripts to deal with extra or no directories.

Both are not really pleasant or really feasible options.

Does anyone know of a better alternative to using the CopyFiles@ task which can handle folder trees? This really feels like a problem that was solved in de 1970's.

The CopyFiles@ would work if it had separate FlattenParentFolders and FlattenSubFolders parameters but it doesn't.

For clarification I'm trying to copy from a folder structure like:

A/B/C/D/E/F/G
The D/E/F/G part to:
X/D/E/F/G
The first option tells me to first copy D, then copy all folders at E, then all at F then all at G RBAR-style.
The second option tells me to make a X/D containing all the files of D/E/F/G or let the output be X/A/B/C/D/E/F/G and then changing all scripts/downline tasks to either handle the X/D or the X/A/B/C/D/E/F/G situation.
neither is what I want to do.
Would there be another task that is capable of doing this? Would I need to write a script that would handle this relocating of trees within a pipeline?

I've tried using the CopyFiles@ task to replace the deprecated DownloadBuildArtifacts@ using several methods and parameters, but for complex situations it does not seem compatible. I expected those to be functionally compatible, but they are not.


Solution

  • There are currently no built-in tasks in DevOps that can meet your needs. It is recommended that you implement your needs by writing scripts yourself, or you can develop such a task yourself.