[CI] [TeamCity] Build master and 7.x hourly, others daily/on merge (#89184)

This commit is contained in:
Brian Seeders 2021-01-25 13:57:56 -05:00 committed by GitHub
parent edb5e35151
commit 7d50fbbf6d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 90 additions and 1 deletions

View file

@ -22,6 +22,14 @@ fun isReportingEnabled(): Boolean {
return ENABLE_REPORTING;
}
// master and 7.x get committed to so often, we only want to run full CI for them hourly
// but for other branches, we can run daily and on merge
fun isHourlyOnlyBranch(): Boolean {
val branch = getProjectBranch()
return branch == "master" || branch.matches("""^[0-9]+\.x$""".toRegex())
}
fun makeSafeId(id: String): String {
return id.replace(Regex("[^a-zA-Z0-9_]"), "_")
}

37
.teamcity/src/builds/DailyCi.kt vendored Normal file
View file

@ -0,0 +1,37 @@
package builds
import addSlackNotifications
import areTriggersEnabled
import dependsOn
import getProjectBranch
import jetbrains.buildServer.configs.kotlin.v2019_2.BuildType
import jetbrains.buildServer.configs.kotlin.v2019_2.FailureAction
import jetbrains.buildServer.configs.kotlin.v2019_2.triggers.schedule
object DailyCi : BuildType({
id("Daily_CI")
name = "Daily CI"
description = "Runs everything in CI, daily"
type = Type.COMPOSITE
paused = !areTriggersEnabled()
triggers {
schedule {
schedulingPolicy = cron {
hours = "0"
minutes = "0"
}
branchFilter = "refs/heads/${getProjectBranch()}"
triggerBuild = always()
withPendingChangesOnly = false
}
}
dependsOn(
FullCi
) {
onDependencyCancel = FailureAction.ADD_PROBLEM
}
addSlackNotifications()
})

34
.teamcity/src/builds/OnMergeCi.kt vendored Normal file
View file

@ -0,0 +1,34 @@
package builds
import addSlackNotifications
import areTriggersEnabled
import dependsOn
import getProjectBranch
import jetbrains.buildServer.configs.kotlin.v2019_2.BuildType
import jetbrains.buildServer.configs.kotlin.v2019_2.FailureAction
import jetbrains.buildServer.configs.kotlin.v2019_2.triggers.vcs
object OnMergeCi : BuildType({
id("OnMerge_CI")
name = "On Merge CI"
description = "Runs everything in CI, on each commit"
type = Type.COMPOSITE
paused = !areTriggersEnabled()
maxRunningBuilds = 1
triggers {
vcs {
perCheckinTriggering = false
branchFilter = "refs/heads/${getProjectBranch()}"
}
}
dependsOn(
FullCi
) {
onDependencyCancel = FailureAction.ADD_PROBLEM
}
addSlackNotifications()
})

View file

@ -7,6 +7,7 @@ import builds.oss.*
import builds.test.*
import CloudProfile
import co.elastic.teamcity.common.googleCloudProfile
import isHourlyOnlyBranch
import jetbrains.buildServer.configs.kotlin.v2019_2.*
import jetbrains.buildServer.configs.kotlin.v2019_2.projectFeatures.slackConnection
import templates.KibanaTemplate
@ -136,7 +137,16 @@ fun Kibana(config: KibanaConfiguration = KibanaConfiguration()) : Project {
buildType(FullCi)
buildType(BaselineCi)
buildType(HourlyCi)
// master and 7.x get committed to so often, we only want to run full CI for them hourly
// but for other branches, we can run daily and on merge
if (isHourlyOnlyBranch()) {
buildType(HourlyCi)
} else {
buildType(DailyCi)
buildType(OnMergeCi)
}
buildType(PullRequestCi)
}