Ashish Chandra
Ashish Chandra

Reputation: 381

TFS Build is downloading all branches source code of a project, which is increasing the space consumed on TFS Server

We are using TFS to build & move source code to Web Server. Before build, files are locally copied into TFS Server. In TFS code is organized as shown in image.

Now, builds are configured on the Website Level (QA-Web1). But after the build, all the files are downloaded (for every branch and every website). This is increasing the size continuously on server, and either manual clearing is required, or space needs to be added on the server.

Is there any way to limit the source code download to only the required folder?

Also, how can this action be taken for deleting existing folders? Files are created in a folder with name as numeric which has no relation with the build name. Is there any mapping between the number and the build name?

TFS Code Arrangement

Example of Folder Created on TFS Server

Sample Build Definition

Upvotes: 1

Views: 446

Answers (3)

Ashish Chandra
Ashish Chandra

Reputation: 381

Solution suggested by PatrickLu-MSFT. "Changed the Map (in Repository) section to fetch specific Folder, instead of the parent Project Folder" Now only required folder is getting downloaded in the Agent folder on server.enter image description here

Upvotes: 0

PatrickLu-MSFT
PatrickLu-MSFT

Reputation: 51093

According to your screenshot, TFSAgent_Builddata_DEVQA should be your build agent folder on workspace.

The variable Agent.BuildDirectory

The local path on the agent where all folders for a given build pipeline are created.

There is not any mapping between the number and the build name. ..\TFSAgent_Builddata_DEVQA\525 For each build definition, it will create a folder (e.g. 1, 2, 3, 4...525). We can't influence the number.

For the concept of this part, you could also take a look at this similar question: Increment in _work directory

For sub folders:

  • ..\TFSAgent_Builddata_DEVQA\525\a equal to Build.ArtifactStagingDirectory The local path on the agent where any artifacts are copied to before being pushed to their destination.
  • ..\TFSAgent_Builddata_DEVQA\525\b equal to Build.BinariesDirectory The local path on the agent you can use as an output folder for compiled binaries.
  • ..\TFSAgent_Builddata_DEVQA\525\s equal to Build.SourcesDirectory The local path on the agent where your source code files are downloaded.

Source Link

To reduce the disk space of your build agent, you could go to Get sources -- Workspace mappings as the screenshot shows, and make sure you have mapped the project you want to build.

enter image description here

Include with a type value of Map only the folders that your build pipeline requires. If a subfolder of a mapped folder contains files that the build pipeline does not require, map it with a type value of Cloak. For more details please refer our official tutorial here: Mappings


For other ways:

  1. You can specify build retention policies, which will automatically delete old completed builds to minimize clutter. You modify these policies on the Retention tab of your build definition.
  2. Use "Delete Files" utility task. The $(Agent.BuildDirectory) and $(Build.SourcesDirectory)variables are useful for this. It will delete files after built successfully. For more info please refer: Clear the work folder after each build

Upvotes: 2

Daniel Mann
Daniel Mann

Reputation: 59018

You need to set your build's workspace appropriately. You have your workspace mapped too broadly, probably to the root ($/TFS Project). You need to scope it more narrowly. This can be done on the Repository tab.

Upvotes: 0

Related Questions