Cleanup

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





Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
inner class BaseRuleWrapper

Holds a base rule

Link copied to clipboard
class KeepRule

Specifies a keep rule. A keep rule defines what particular data to preserve during the clean-up. Multiple keep rules can be assigned to a project or build configuration.

Properties

Link copied to clipboard
Link copied to clipboard

Specifies whether dependency builds should be cleaned. Null means use default, true means prevent clean-up, false means don't prevent clean-up.

Functions

Link copied to clipboard
fun all(days: Int? = null, builds: Int? = null)

Adds an 'everything'-level clean-up rule. Either days or builds must be non-null. If they are both null, clean-up will not be configured.

Link copied to clipboard
fun artifacts(days: Int? = null, builds: Int? = null, artifactPatterns: String? = null)

Adds an artifacts-level clean-up rule. Either days or builds must be non-null. If they are both null, clean-up will not be configured.

Link copied to clipboard

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.

Link copied to clipboard

Copies the receiver cleanup

Link copied to clipboard

Copies the receiver cleanup to the specified target

Link copied to clipboard

Disables an inherited keep rule

fun disableKeepRule(idToDisable: String)

Disables an inherited keep rule by its ID

Link copied to clipboard

Finds a keep rule with the specified id

Link copied to clipboard
fun history(days: Int? = null, builds: Int? = null)

Adds a history-level clean-up rule. Either days or builds must be non-null. If they are both null, clean-up will not be configured.

Link copied to clipboard

Creates and registeres a new keep rule for this clean-up definition. IDs must be specified for all keep rules.

Link copied to clipboard
fun option(name: String, value: Boolean)

Adds a specified clean-up option

Link copied to clipboard
fun validate(consumer: ErrorConsumer)