cleanup

fun cleanup(init: Cleanup.() -> Unit)

Configures project clean-up rules

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
}
}





Parameters

init

function to initialize clean-up rules