How Build Retention Policy Works in VSTS/Azure DevOps Server 2019 using Build Definitions

HOW TO -️ October 18, 2021

Hi , I want to know How Build Retention Policy Work Internally.

  1. I have a shared location where outputs of all Builds copied.Build retention Policy deletes those outputs/artifacts according to mentioned policy which is understood.
  2. Does this delete everything (ALL Folder levels) in shared folder: \SharedLocationMachineName\TFSBuilds\ProjectName\$(Build.BuildNumber)\Deployment\binaries\installer\setup

or it only works what is inside at single folder level: \SharedLocationMachineName\TFSBuilds\ProjectName\$(Build.BuildNumber)

Second Question: What is difference between Copy Files and "Publish Build Artifacts" tasks. Which one should be used in which scenario?

Does these tasks effect Deletion in Build Retention Policy?

What are best practices to use these tasks: How many levels of folders can be defined after Main Publishing Variable Folder?

Objective: We have a central location where different teams are sharing or publishing their build artifacts. In some folders , Build deletion is not working according to Build Retention Policy. I can see our developers used lot of COPY FILES tasks in Build definitions which has long paths: I want to know into the things. May be the best way to improve Build definitions.


Please explain what you would like to achieve. E.g: What is currently not working? What did you try to solve the issue? What kind of impediments occur? What did you find on the internet and why did the results not solve the issue? Please explain how the setup looks like, e.g. what services are deployed. Please edit the Q&A.