What is the difference between Copy Files vs Publish Artifact task in VSTS?

Viewed 13644

In my Copy Files task, I am copying the required files to the file share location from which I will be doing the deployment. What is the use of publishing artifact step? Or it is obsolete in my case. I am confused about the what values should be put in the boxes.

enter image description here

2 Answers
  • If you need to copy files/artifacts to VSTS server, Publish Artifacts task is the only option (by selecting Server for Artifact Type option).
  • If you need to copy files/artifacts to a share path, both Publish Artifacts task and Copy Files task are ok. And Copy Files task is a little more flexible than Publish Artifacts task since you can specify which files to be copied to share path in Contents option.

And for your situation, you can use any of the tasks (Publish Artifacts task and Copy Files task). Since you only need to copy the contents under $(build.artifactstagingdirectory) to the share path \\my\share\$(Build.DefinitionName)\$(Build.BuildNumber), both the tasks can also achieve it.

  • If you use the Publish Artifacts task, settings as you specified in the picture is ok. It will copy the contents under $(build.artifactstagingdirectory) to \\my\share\$(Build.DefinitionName)\$(Build.BuildNumber)\drop.

  • If you use the Copy Files task, settings as be set as below. It will also the same result as the Publish Artifacts task.

    enter image description here

I have found out another difference which is when builds are cleaned up (deleted either manually or when retention rule deletes them).

When using Publish Artifacts task with a shared folder as destination, cleanup of the drop folder is done. When using Copy Files task, cleanup of the drop folder is not done.

If cleanup of shared folder is an issue for you, switching to using the Publish Artifacts task seems like a good idea.

Hope this helps.

Related