Post Build Cleanup
Did you ever run out of disk space on your build machine, because there were so many sources and binaries from previous build runs? Then this extension is for you!
By default, the clean option of a build definition deletes files before the build starts. Thus, every build leaves behind sources and binaries on your build machine, and those files accumulate and eat up your disk space. If you're not running incremental builds, those files are not needed after the build has finished.
The Post Build Cleanup task deletes unwanted files from your build agent, after your build has run, thus, saving precious disk space.
You can find the changes notes for this task here.
If you need help with the extension or run into issues, please contact us at firstname.lastname@example.org.
Adding the Task to a Build Definition
Simply add the Post Build Cleanup task (in task category Utility) to your build definition. Starting with v3.1.0, the task can be placed anywhere in your pipeline. Since post-job scripts are executed in reverse order of their corresponding task scripts, we recommend to put the Post Build Cleanup task as the first task in your pipeline. This ensures that every other post-job script is executed before we clean files from your build agent.
Behavior of the Task
The task behavior is directly linked to the clean options you select in your build definition's Repository settings. In the new build UI the clean option has been moved to the Get sources task in the Tasks list.
If the Clean option is unchecked, the task does nothing. Otherwise, the task behavior depends on the selected value for Clean options and mimics the pre-build cleanup behavior:
Support for Team Foundation Server 2015
Team Foundation Server 2015 does not support the Clean options parameter. To configure the cleanup behavior, set the build variable Build.Clean as described here. The values of Build.Clean are matched to the Clean options parameter as follows:
Because the build agent that comes with Team Foundation Server 2015 does contain a Git command line client, you must install Git on the build machine, in order to support source cleanup. If Git is not installed, the task will fall back to delete all contents of the $(Build.SourcesDirectory).