Clean-Up
Last modified: 20 April 2023TeamCity 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 rules for individual build configurations and defaults are configured under Administration > Build History Clean-Up.
It is recommended to configure clean-up policy 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)
A clean-up policy defines when and what data to clean. The default clean-up policy can be configured for all the build configurations. The clean-up policy can also be defined 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).
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.
(build log messages, developers' changes, artifacts, statistical data and so on)
Clean-up policy can be adjusted at Administration > Build History Clean-Up Policy page.
The following cleanup level are available:
remove only the build artifacts (all other data is preserved. Build Artifact are also preserved);
remove the build history entry (all the build data is deleted except for builds statistics values that are visible in the statistics charts);
remove 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).
Clean-Up for Dependent Builds
TeamCity preserves builds that are used in other builds by either Dependent Build.
This behavior is regulated by an option that allows to protect artifacts of the builds that were used as a source of artifact dependencies ("Prevent dependency artifacts clean-up" option in Dependencies section of the Edit Clean Up Rules). In previous versions of TeamCity the option is ON by default, since TeamCity 6.5 this option is OFF by default. Also since TeamCity 6.5 you can set default value for this option in the default cleanup rule.
Example: Say, a build configuration A has an artifact dependency on B. If Prevent dependency artifacts clean-up option is enabled for A, the builds of B that provided artifacts for the builds of A will not be processed while cleaning artifacts, so that artifacts will be preserved.
See also:
Concepts: Dependent Build
Thanks for your feedback!