diff --git a/.teamcity/additionalConfiguration.kt b/.teamcity/additionalConfiguration.kt index 70827b9f..ed990323 100644 --- a/.teamcity/additionalConfiguration.kt +++ b/.teamcity/additionalConfiguration.kt @@ -3,9 +3,8 @@ * Use of this source code is governed by the Apache 2.0 License that can be found in the LICENSE.txt file. */ -import jetbrains.buildServer.configs.kotlin.v2019_2.BuildType import jetbrains.buildServer.configs.kotlin.v2019_2.Project -fun Project.additionalConfiguration(buildVersion: BuildType) { - subProject(benchmarksProject(buildVersion)) +fun Project.additionalConfiguration() { + subProject(benchmarksProject(existingBuildVersion())) } \ No newline at end of file diff --git a/.teamcity/settings.kts b/.teamcity/settings.kts index f644c815..320cc9b2 100644 --- a/.teamcity/settings.kts +++ b/.teamcity/settings.kts @@ -45,24 +45,24 @@ project { } } - val deployConfigure = deployConfigure().apply { + val deployVersion = deployVersion().apply { dependsOnSnapshot(buildAll, onFailure = FailureAction.IGNORE) } - val deploys = platforms.map { deploy(it, deployConfigure) } - val deployPublish = deployPublish(deployConfigure).apply { + val deploys = platforms.map { deploy(it, deployVersion) } + val deployPublish = deployPublish(deployVersion).apply { dependsOnSnapshot(buildAll, onFailure = FailureAction.IGNORE) deploys.forEach { dependsOnSnapshot(it) } } - buildTypesOrder = listOf(buildAll, buildVersion, *builds.toTypedArray(), deployPublish, deployConfigure, *deploys.toTypedArray()) + buildTypesOrder = listOf(buildAll, buildVersion, *builds.toTypedArray(), deployPublish, deployVersion, *deploys.toTypedArray()) - additionalConfiguration(buildVersion) + additionalConfiguration() } fun Project.buildVersion() = BuildType { - id("Build_Version") + id(BUILD_CONFIGURE_VERSION_ID) this.name = "Build (Configure Version)" commonConfigure() @@ -84,7 +84,7 @@ fun Project.buildVersion() = BuildType { }.also { buildType(it) } fun Project.buildAll(versionBuild: BuildType) = BuildType { - id("Build_All") + id(BUILD_ALL_ID) this.name = "Build (All)" type = BuildTypeSettings.Type.COMPOSITE @@ -129,8 +129,8 @@ fun Project.build(platform: Platform, versionBuild: BuildType) = buildType("Buil artifactRules = "+:build/maven=>maven\n+:build/api=>api" } -fun Project.deployConfigure() = BuildType { - id("Deploy_Configure") +fun Project.deployVersion() = BuildType { + id(DEPLOY_CONFIGURE_VERSION_ID) this.name = "Deploy (Configure Version)" commonConfigure() @@ -159,7 +159,7 @@ fun Project.deployConfigure() = BuildType { }.also { buildType(it) } fun Project.deployPublish(configureBuild: BuildType) = BuildType { - id("Deploy_Publish") + id(DEPLOY_PUBLISH_ID) this.name = "Deploy (Publish)" type = BuildTypeSettings.Type.COMPOSITE dependsOnSnapshot(configureBuild) diff --git a/.teamcity/utils.kt b/.teamcity/utils.kt index 12c98ce0..7b087dde 100644 --- a/.teamcity/utils.kt +++ b/.teamcity/utils.kt @@ -32,6 +32,22 @@ fun Platform.buildTypeId(): String = buildTypeName().substringBefore(" ") fun Platform.teamcityAgentName(): String = buildTypeName() +const val BUILD_CONFIGURE_VERSION_ID = "Build_Version" +const val BUILD_ALL_ID = "Build_All" +const val DEPLOY_CONFIGURE_VERSION_ID = "Deploy_Configure" +const val DEPLOY_PUBLISH_ID = "Deploy_Publish" + +private fun existingBuildId(suffix: String): String = "RootProjectId_$suffix" +private fun Project.existingBuildWithId(id: String): BuildType = buildTypes.single { it.id.toString() == existingBuildId(id) } + +fun Project.existingBuildVersion(): BuildType = existingBuildWithId(BUILD_CONFIGURE_VERSION_ID) +fun Project.existingBuildAll(): BuildType = existingBuildWithId(BUILD_ALL_ID) +fun Project.existingBuild(platform: Platform): BuildType = existingBuildWithId("Build_${platform.buildTypeId()}") +fun Project.existingDeployVersion(): BuildType = existingBuildWithId(DEPLOY_CONFIGURE_VERSION_ID) +fun Project.existingDeployPublish(): BuildType = existingBuildWithId(DEPLOY_PUBLISH_ID) +fun Project.existingDeploy(platform: Platform): BuildType = existingBuildWithId("Deploy_${platform.buildTypeId()}") + + fun Project.buildType(name: String, platform: Platform, configure: BuildType.() -> Unit) = BuildType { // ID is prepended with Project ID, so don't repeat it here // ID should conform to identifier rules, so just letters, numbers and underscore