microsoft / azure-pipelines-tasks

Tasks for Azure Pipelines
https://aka.ms/tfbuild
MIT License
3.47k stars 2.6k forks source link

PublishBuildArtifactsV1 Fails to publish sub directory that is empty #10582

Closed cg3y closed 4 years ago

cg3y commented 5 years ago

Required Information

Question, Bug, or Feature?
Type: Bug

Task Name: PublishBuildArtifacts

Environment

Issue Description

Attempting to publish a folder as a container fails to publish directories that are empty. Directories themselves ARE artifacts and should be included in the container regardless of whether or not they have content.

As an example, assume the following tree:

/root/Dir1 /root/Dir1/file1.txt /root/Dir1/Dir1A /root/Dir2 /root/Dir2/anotherFile.txt

If you attempt to publish /root as a build artifact container type, the resulting artifact is as follows:

/root/Dir1 /root/Dir1/file1.txt /root/Dir2 /root/Dir2/anotherFile.txt

The "/root/Dir1/Dir1A" folder (which is itself an artifact!) is missing.

example publish for the above:

This was run on a windows host on prem.

alexmbaker commented 5 years ago

A couple of observations here:

In this scenario you could consider:

cg3y commented 5 years ago

Hi Alex,

Thanks so much for your reply.,

Regarding your observations...first, you absolutely can add empty folders to a zip archive. Zip archives reflect the directory structure of whatever you add. .7z, .zip, .tar...all allow adding empty folders to them.

Second observation...just because git doesn't capture empty folders doesn't mean that other version control systems operate the same. Git may be widely used but it is far from the best system out there (PlasticSCM is far superior in my opinion), and many do indeed capture empty folders (as preserving a tree is meaningful and this is a git shortcoming). Directory trees (whether they have files are not) are meaningful to certain apps or in certain situations (such as providing skeleton outlines for structure) and should be considered artifacts.

Placing zero byte placeholders to work around a bug is fine, but it doesn't alleviate the fact that this is a bug that needs to be fixed (because a zero byte placeholder is not an artifact I want in my tree).

Adding a script to work around an artifact not being added by adding it after the missing artifact is discovered kind of defeats the purpose of creating the artifact in the first place.

And back to your first point, my work-around was simply to zip up my tree and add the zip as the artifact. Then I just unzip my artifact when I pull it down. This preserves the directory tree (again, showing that empty directories absolutely get zipped up just fine).

So I have a work-around, but that doesn't mean this isn't a bug--we should not have to have work-arounds.

leantk commented 4 years ago

This issue is stale because it has been open for a year with no activity. Remove the stale label or comment on the issue otherwise this will be closed in 5 days