Clean-Up
TeamCity has a feature of automatic deletion of the data belonging to old builds. It is called Clean-up and can be run manually or each day by schedule (which is recommended). Clean-up settings are configured under Administration | Project-related Settings | Build History Clean-up. It is recommended to configure clean-up rules to remove builds that are no longer necessary to free disk space, remove builds from TeamCity UI and reduce TeamCity load processing no longer necessary data. The cleanup deletes the data stored under /system
and in the database. Also, during cleanup time the server performs various maintenance tasks (e.g. resets VCS full patch caches).
Clean-up Rules
A clean-up rule defines when and what data to clean. The default clean-up rule applies to all build configurations and can be configured. However, you can define a clean-up rule for a specific build configuration to override default. In each rule, you can define a number of successful builds to preserve, and/or a length of time that builds should be kept in history (e.g. keep builds for 7 days).
The following cleanup levels are available:
Clean artifacts (all other data is preserved. Build Artifact are also preserved);
Clean history (all the build data is deleted except for builds statistics values that are visible in the statistics charts);
Clean everything (no build data remains in TeamCity). Each level includes all listed before it.
For each of the above items you can specify:
the number of days. Builds older then the number of days specified will be cleaned with the specified level. A day is equivalent to a 24-hour period, not a calendar day;
the number of successful builds. Only builds older then the last matching successful build will be cleaned with the level specified (all the failed builds between preserved successful ones are kept).
The second rule is only taken into account if there are successful builds in the build configuration.
When both conditions are specified, only the builds which should be cleaned according to both rules will be actually cleaned (TeamCity finds the oldest build to preserve according to each of the the rules and then cleans all builds older then the oldest one of the two found.)
There are builds that preserve all their data and are not cleaned during cleanup. These are:
builds used as a source for Configuring Dependencies in other builds when "Prevent dependency artifacts clean-up" option is enabled. See Clean-Up-for-Dependent-Builds below;
builds of build configurations that were deleted less then one day ago.
Clean-up for Dependent Builds
TeamCity always preserves builds which are used as Dependent Build in other builds. These builds and their associated data (e.g. artifacts) are never deleted by the cleanup procedure.
TeamCity can optionally preserve builds which are used in other builds by Dependent Build. This behavior is regulated by the option in Dependencies section of the Edit Clean Up Rules dialog.
"Use default" choice uses the option configured in the default cleanup rule. "Prevent cleanup" choice protects builds (and their artifacts) which were used as a source of artifact dependencies for the builds of the current build configuration. "Clean-up using own rules" choice makes cleanup-related processing of the dependency builds disregard the fact that they are used by the builds of the current build configuration.
Example: Say, a build configuration A has an artifact dependency on B. If Prevent cleanup option is used for A, the builds of B that provided artifacts for the builds of A will not be processed while cleaning the builds, so the builds and their artifacts will be preserved.