Cleaning up your TFS Build Server

The Team Foundation Build Server at one of our clients was getting out of hand. We set up continuous integration so we are getting a lot of builds per day. The server had hundreds of builds that we just didn't need hanging around anymore. We asked our IT guy extraordinaire, Max if he could write us a script to automate the cleanup of TFS Builds. He rose to the challenge and now we have one.

He wrote the VB Script attached to this post. I tried it out on the server last Friday and it worked great. Here is the command to call it.

cscript TFSBuildCleanup.vbs http://<Server>:<port> <Project> <Build Location> <BuildType> <Days>

  • Server = Team Foundation Server
  • Port = TFS port
  • Build Location = Folder that contains the builds on the server (ie: c:\Builds)
  • BuildType = Name of the build Type to remove
  • Number of days of build to keep. If you put seven it will remove all the build 8 days and older.

I set it up as a task on the build server to run each night.

I hope it's useful to someone out there.