Cleanup
Specifies clean-up rules for project, build configuration, or template
Example. Keep all builds finished within 5 days after the last build
cleanup {
keepRule {
id = "MyCleanupRule"
keepAtLeast = days(5) {
since = lastBuild()
}
dataToKeep = everything()
applyPerEachBranch = true
preserveArtifactsDependencies = true
}
}
This cleanup rule tells TeamCity to keep all the builds which were fiished within 5 days since the last build.
The builds are kept per each branch individually.
Example. Keep not more than 10 personal builds
cleanup {
keepRule {
id = "Keep10PersonalBuilds"
keepAtLeast = builds(10)
applyToBuilds {
inPersonalBuilds = onlyPersonal()
}
dataToKeep = everything()
preserveArtifactsDependencies = true
}
}
Note: this should not be the only cleanup rule in the project, otherwise all other non-personal builds will be removed.
Example. Keep per-build statistics data for every build produced within 365 days since the last build
cleanup {
keepRule {
id = "KeepStatisticsFor1Year"
keepAtLeast = days(365) {
since = lastBuild()
}
dataToKeep = statisticsOnly()
}
}
Note: dataToKeep = statisticsOnly() means that only statistic values will be preserved for the builds, everything else, like build logs, artifacts and the build itself will be removed. Preserved statistics values still allow to show data on the custom charts for such builds.
Example. Sets custom base cleanup rules options.
cleanup {
baseRule {
history(builds = 3, days = 5)
artifacts(builds = 3, days = 5, artifactPatterns = "+:log*")
preventDependencyCleanup = true
}
}
Types
Properties
Specifies whether dependency builds should be cleaned. Null means use default, true means prevent clean-up, false means don't prevent clean-up.
Functions
Specifies a base rule. A base rule defines what data to clean up in general. Allows preserving a specified number of successful builds and/or choose the time period to keep builds in the history.
Disables an inherited keep rule
Disables an inherited keep rule by its ID
Finds a keep rule with the specified id
Creates and registeres a new keep rule for this clean-up definition. IDs must be specified for all keep rules.