From ba204dd82cbc4dd57c7ea96c06084504f3cc8e20 Mon Sep 17 00:00:00 2001 From: Bo Zhang Date: Fri, 7 Oct 2022 13:32:17 +0800 Subject: [PATCH] Cherry pick promotion changes from master --- .teamcity/src/main/kotlin/common/Jvm.kt | 34 +++++++++ .teamcity/src/main/kotlin/common/Os.kt | 7 ++ .../kotlin/common/VersionedSettingsBranch.kt | 41 +++++++++-- .../src/main/kotlin/common/extensions.kt | 27 +++++++ .../kotlin/configurations/Gradleception.kt | 1 - .../main/kotlin/configurations/SmokeTests.kt | 1 - .../promotion/BasePromotionBuildType.kt | 18 ++++- .../BasePublishGradleDistribution.kt | 71 +++++++++++++++++++ .../main/kotlin/promotion/PromotionProject.kt | 12 +++- .../PublishBranchSnapshotFromQuickFeedback.kt | 8 ++- .../promotion/PublishGradleDistribution.kt | 71 ------------------- .../PublishGradleDistributionFullBuild.kt | 38 ++++++++++ .../promotion/PublishNightlySnapshot.kt | 23 ++++-- ...PublishNightlySnapshotFromQuickFeedback.kt | 9 ++- ...SnapshotFromQuickFeedbackStepCheckReady.kt | 34 +++++++++ ...tlySnapshotFromQuickFeedbackStepPromote.kt | 45 ++++++++++++ ...htlySnapshotFromQuickFeedbackStepUpload.kt | 44 ++++++++++++ .../main/kotlin/promotion/PublishRelease.kt | 19 +++-- .../src/main/kotlin/promotion/SanityCheck.kt | 2 + .../kotlin/promotion/StartReleaseCycle.kt | 11 +-- .../kotlin/promotion/StartReleaseCycleTest.kt | 6 +- .../kotlin/ApplyDefaultConfigurationTest.kt | 2 +- .../test/kotlin/CIConfigIntegrationTests.kt | 2 +- .../kotlin/PerformanceTestBuildTypeTest.kt | 2 +- 24 files changed, 414 insertions(+), 114 deletions(-) create mode 100644 .teamcity/src/main/kotlin/common/Jvm.kt create mode 100644 .teamcity/src/main/kotlin/promotion/BasePublishGradleDistribution.kt delete mode 100644 .teamcity/src/main/kotlin/promotion/PublishGradleDistribution.kt create mode 100644 .teamcity/src/main/kotlin/promotion/PublishGradleDistributionFullBuild.kt create mode 100644 .teamcity/src/main/kotlin/promotion/PublishNightlySnapshotFromQuickFeedbackStepCheckReady.kt create mode 100644 .teamcity/src/main/kotlin/promotion/PublishNightlySnapshotFromQuickFeedbackStepPromote.kt create mode 100644 .teamcity/src/main/kotlin/promotion/PublishNightlySnapshotFromQuickFeedbackStepUpload.kt diff --git a/.teamcity/src/main/kotlin/common/Jvm.kt b/.teamcity/src/main/kotlin/common/Jvm.kt new file mode 100644 index 000000000000..aefa96616a3d --- /dev/null +++ b/.teamcity/src/main/kotlin/common/Jvm.kt @@ -0,0 +1,34 @@ +/* + * Copyright 2022 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package common + +interface Jvm { + val version: JvmVersion + val vendor: JvmVendor +} + +data class DefaultJvm( + override val version: JvmVersion, + override val vendor: JvmVendor +) : Jvm + +object BuildToolBuildJvm : Jvm { + override val version: JvmVersion + get() = JvmVersion.java11 + override val vendor: JvmVendor + get() = JvmVendor.openjdk +} diff --git a/.teamcity/src/main/kotlin/common/Os.kt b/.teamcity/src/main/kotlin/common/Os.kt index 663bb8eea4fc..9e93fb6be174 100644 --- a/.teamcity/src/main/kotlin/common/Os.kt +++ b/.teamcity/src/main/kotlin/common/Os.kt @@ -68,3 +68,10 @@ enum class Os( fun javaHome(jvmVersion: JvmVersion, vendor: JvmVendor) = "%${name.toLowerCase()}.$jvmVersion.$vendor.64bit%" } + +enum class Arch(val suffix: String, val nameOnLinuxWindows: String, val nameOnMac: String) { + AMD64("64bit", "amd64", "x86_64"), + AARCH64("aarch64", "aarch64", "aarch64"); + + fun asName() = name.lowercase().toCapitalized() +} diff --git a/.teamcity/src/main/kotlin/common/VersionedSettingsBranch.kt b/.teamcity/src/main/kotlin/common/VersionedSettingsBranch.kt index 0f13823d9f2f..a8be6e9ed7be 100644 --- a/.teamcity/src/main/kotlin/common/VersionedSettingsBranch.kt +++ b/.teamcity/src/main/kotlin/common/VersionedSettingsBranch.kt @@ -2,18 +2,51 @@ package common import jetbrains.buildServer.configs.kotlin.v2019_2.DslContext -data class VersionedSettingsBranch(val branchName: String) { +data class VersionedSettingsBranch(val branchName: String, val enableTriggers: Boolean) { companion object { - val MASTER = VersionedSettingsBranch("master") + private + const val MASTER_BRANCH = "master" + + private + const val RELEASE_BRANCH = "release" + + private + const val EXPERIMENTAL_BRANCH = "experimental" + + private + val mainBranches = setOf(MASTER_BRANCH, RELEASE_BRANCH) fun fromDslContext(): VersionedSettingsBranch { val branch = DslContext.getParameter("Branch") // TeamCity uses a dummy name when first running the DSL if (branch.contains("placeholder-1")) { - return MASTER + return VersionedSettingsBranch(MASTER_BRANCH, true) } - return VersionedSettingsBranch(branch.toLowerCase()) + return VersionedSettingsBranch(branch.lowercase(), mainBranches.contains(branch.lowercase())) } } + + val isMaster: Boolean + get() = branchName == MASTER_BRANCH + val isRelease: Boolean + get() = branchName == RELEASE_BRANCH + val isExperimental: Boolean + get() = branchName == EXPERIMENTAL_BRANCH + + fun vcsRootId() = "Gradle${branchName.toCapitalized()}" + + fun promoteNightlyTaskName() = nightlyTaskName("promote") + fun prepNightlyTaskName() = nightlyTaskName("prep") + + fun promoteMilestoneTaskName(): String = when { + isRelease -> "promoteReleaseMilestone" + else -> "promoteMilestone" + } + + private fun nightlyTaskName(prefix: String): String = when { + isMaster -> "${prefix}Nightly" + isRelease -> "${prefix}ReleaseNightly" + else -> "${prefix}PatchReleaseNightly" + } } diff --git a/.teamcity/src/main/kotlin/common/extensions.kt b/.teamcity/src/main/kotlin/common/extensions.kt index 5cbc0bcce0be..ee0f123dcde5 100644 --- a/.teamcity/src/main/kotlin/common/extensions.kt +++ b/.teamcity/src/main/kotlin/common/extensions.kt @@ -36,6 +36,7 @@ import jetbrains.buildServer.configs.kotlin.v2019_2.buildSteps.script import jetbrains.buildServer.configs.kotlin.v2019_2.failureConditions.BuildFailureOnText import jetbrains.buildServer.configs.kotlin.v2019_2.failureConditions.failOnText import jetbrains.buildServer.configs.kotlin.v2019_2.ui.add +import java.util.Locale fun BuildSteps.customGradle(init: GradleBuildStep.() -> Unit, custom: GradleBuildStep.() -> Unit): GradleBuildStep = GradleBuildStep(init) @@ -169,3 +170,29 @@ fun Dependencies.compileAllDependency(compileAllId: String) { artifactRules = "build-receipt.properties => incoming-distributions" } } + +fun BuildType.paramsForBuildToolBuild(buildJvm: Jvm = BuildToolBuildJvm, os: Os, arch: Arch = Arch.AMD64) { + params { + param("env.BOT_TEAMCITY_GITHUB_TOKEN", "%github.bot-teamcity.token%") + param("env.GRADLE_CACHE_REMOTE_PASSWORD", "%gradle.cache.remote.password%") + param("env.GRADLE_CACHE_REMOTE_URL", "%gradle.cache.remote.url%") + param("env.GRADLE_CACHE_REMOTE_USERNAME", "%gradle.cache.remote.username%") + + param("env.JAVA_HOME", javaHome(buildJvm, os, arch)) + param("env.GRADLE_OPTS", "-Xmx1536m -XX:MaxPermSize=384m") + param("env.ANDROID_HOME", os.androidHome) + param("env.ANDROID_SDK_ROOT", os.androidHome) + param("env.GRADLE_INTERNAL_REPO_URL", "%gradle.internal.repository.url%") + if (os == Os.MACOS) { + // Use fewer parallel forks on macOs, since the agents are not very powerful. + param("maxParallelForks", "2") + } + if (os == Os.LINUX || os == Os.MACOS) { + param("env.LC_ALL", "en_US.UTF-8") + } + } +} + +fun String.toCapitalized() = this.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() } + +fun javaHome(jvm: Jvm, os: Os, arch: Arch = Arch.AMD64) = "%${os.name.lowercase()}.${jvm.version}.${jvm.vendor}.${arch.suffix}%" diff --git a/.teamcity/src/main/kotlin/configurations/Gradleception.kt b/.teamcity/src/main/kotlin/configurations/Gradleception.kt index 1a143f7e1098..3ff7600ba273 100644 --- a/.teamcity/src/main/kotlin/configurations/Gradleception.kt +++ b/.teamcity/src/main/kotlin/configurations/Gradleception.kt @@ -3,7 +3,6 @@ package configurations import common.Os.LINUX import common.buildToolGradleParameters import common.customGradle -import common.gradleWrapper import common.requiresNotEc2Agent import jetbrains.buildServer.configs.kotlin.v2019_2.BuildSteps import jetbrains.buildServer.configs.kotlin.v2019_2.buildSteps.GradleBuildStep diff --git a/.teamcity/src/main/kotlin/configurations/SmokeTests.kt b/.teamcity/src/main/kotlin/configurations/SmokeTests.kt index 4a90d783b851..011f7ac8855f 100644 --- a/.teamcity/src/main/kotlin/configurations/SmokeTests.kt +++ b/.teamcity/src/main/kotlin/configurations/SmokeTests.kt @@ -4,7 +4,6 @@ import common.JvmCategory import common.Os.LINUX import common.cleanAndroidUserHome import common.requiresNotEc2Agent -import jetbrains.buildServer.configs.kotlin.v2019_2.buildFeatures.parallelTests import model.CIBuildModel import model.Stage diff --git a/.teamcity/src/main/kotlin/promotion/BasePromotionBuildType.kt b/.teamcity/src/main/kotlin/promotion/BasePromotionBuildType.kt index d625b3571239..3d1e540ba3a7 100644 --- a/.teamcity/src/main/kotlin/promotion/BasePromotionBuildType.kt +++ b/.teamcity/src/main/kotlin/promotion/BasePromotionBuildType.kt @@ -16,7 +16,9 @@ package promotion +import common.BuildToolBuildJvm import common.Os +import common.paramsForBuildToolBuild import common.requiresNotEc2Agent import common.requiresOs import jetbrains.buildServer.configs.kotlin.v2019_2.AbsoluteId @@ -38,9 +40,21 @@ abstract class BasePromotionBuildType(vcsRootId: String, cleanCheckout: Boolean requiresNotEc2Agent() } + paramsForBuildToolBuild(BuildToolBuildJvm, Os.LINUX) + params { - param("env.GRADLE_INTERNAL_REPO_URL", "%gradle.internal.repository.url%") - param("env.GRADLE_ENTERPRISE_ACCESS_KEY", "%ge.gradle.org.access.key%;%e.grdev.net.access.key%") + password("env.GRADLE_ENTERPRISE_ACCESS_KEY", "%ge.gradle.org.access.key%;%e.grdev.net.access.key%") + password("env.ORG_GRADLE_PROJECT_botGradleGitHubToken", "%github.bot-gradle.token%") + } + + features { + // https://www.jetbrains.com/help/teamcity/shared-resources.html#Viewing+Shared+Resources+Usage + // https://blog.jetbrains.com/teamcity/2013/05/explaining-the-shared-resources-plugin/ + // we only allow 1 promotion job running at the same time to avoid website xml conflicts + feature { + type = "JetBrains.SharedResources" + param("locks-param", "WebsiteReleasesXml writeLock") + } } } } diff --git a/.teamcity/src/main/kotlin/promotion/BasePublishGradleDistribution.kt b/.teamcity/src/main/kotlin/promotion/BasePublishGradleDistribution.kt new file mode 100644 index 000000000000..b18aa085dc1d --- /dev/null +++ b/.teamcity/src/main/kotlin/promotion/BasePublishGradleDistribution.kt @@ -0,0 +1,71 @@ +/* + * Copyright 2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package promotion + +import common.gradleWrapper +import jetbrains.buildServer.configs.kotlin.v2019_2.BuildSteps +import jetbrains.buildServer.configs.kotlin.v2019_2.RelativeId +import vcsroots.gradlePromotionMaster + +abstract class BasePublishGradleDistribution( + // The branch to be promoted + val promotedBranch: String, + val prepTask: String, + val triggerName: String, + val gitUserName: String = "bot-teamcity", + val gitUserEmail: String = "bot-teamcity@gradle.com", + val extraParameters: String = "", + vcsRootId: String = gradlePromotionMaster, + cleanCheckout: Boolean = true +) : BasePromotionBuildType(vcsRootId, cleanCheckout) { + + init { + artifactRules = """ + **/build/git-checkout/subprojects/base-services/build/generated-resources/build-receipt/org/gradle/build-receipt.properties + **/build/distributions/*.zip => promote-build-distributions + **/build/website-checkout/data/releases.xml + **/build/git-checkout/build/reports/integTest/** => distribution-tests + **/smoke-tests/build/reports/tests/** => post-smoke-tests + **/build/version-info.properties => version-info.properties + """.trimIndent() + + dependencies { + snapshot(RelativeId("Check_Stage_${this@BasePublishGradleDistribution.triggerName}_Trigger")) { + synchronizeRevisions = false + } + } + + steps { + buildStep( + this@BasePublishGradleDistribution.extraParameters, + this@BasePublishGradleDistribution.gitUserName, + this@BasePublishGradleDistribution.gitUserEmail, + this@BasePublishGradleDistribution.triggerName, + this@BasePublishGradleDistribution.prepTask, + "checkNeedToPromote" + ) + } + } +} + +fun BuildSteps.buildStep(extraParameters: String, gitUserName: String, gitUserEmail: String, triggerName: String, prepTask: String, stepTask: String) { + gradleWrapper { + name = "Promote" + tasks = "$prepTask $stepTask" + gradleParams = """-PcommitId=%dep.${RelativeId("Check_Stage_${triggerName}_Trigger")}.build.vcs.number% $extraParameters "-PgitUserName=$gitUserName" "-PgitUserEmail=$gitUserEmail" %additional.gradle.parameters% """ + } +} diff --git a/.teamcity/src/main/kotlin/promotion/PromotionProject.kt b/.teamcity/src/main/kotlin/promotion/PromotionProject.kt index cede9dd4f54c..b0136da6fd95 100644 --- a/.teamcity/src/main/kotlin/promotion/PromotionProject.kt +++ b/.teamcity/src/main/kotlin/promotion/PromotionProject.kt @@ -1,6 +1,9 @@ package promotion +import common.BuildToolBuildJvm +import common.Os import common.VersionedSettingsBranch +import common.javaHome import jetbrains.buildServer.configs.kotlin.v2019_2.Project class PromotionProject(branch: VersionedSettingsBranch) : Project({ @@ -10,10 +13,13 @@ class PromotionProject(branch: VersionedSettingsBranch) : Project({ buildType(SanityCheck) buildType(PublishNightlySnapshot(branch)) buildType(PublishNightlySnapshotFromQuickFeedback(branch)) + buildType(PublishNightlySnapshotFromQuickFeedbackStepCheckReady(branch)) + buildType(PublishNightlySnapshotFromQuickFeedbackStepUpload(branch)) + buildType(PublishNightlySnapshotFromQuickFeedbackStepPromote(branch)) buildType(PublishBranchSnapshotFromQuickFeedback) buildType(PublishMilestone(branch)) - if (branch == VersionedSettingsBranch.MASTER) { + if (branch.isMaster) { buildType(StartReleaseCycle) buildType(StartReleaseCycleTest) } else { @@ -28,10 +34,12 @@ class PromotionProject(branch: VersionedSettingsBranch) : Project({ password("env.DOTCOM_DEV_DOCS_AWS_SECRET_KEY", "%dotcomDevDocsAwsSecretKey%") param("env.DOTCOM_DEV_DOCS_AWS_ACCESS_KEY", "AKIAX5VJCER2X7DPYFXF") password("env.ORG_GRADLE_PROJECT_sdkmanToken", "%sdkmanToken%") - param("env.JAVA_HOME", "%linux.java11.openjdk.64bit%") + param("env.JAVA_HOME", javaHome(BuildToolBuildJvm, Os.LINUX)) param("env.ORG_GRADLE_PROJECT_artifactoryUserName", "%gradle.internal.repository.build-tool.publish.username%") password("env.ORG_GRADLE_PROJECT_infrastructureEmailPwd", "%infrastructureEmailPwd%") param("env.ORG_GRADLE_PROJECT_sdkmanKey", "8ed1a771bc236c287ad93c699bfdd2d7") + param("env.PGP_SIGNING_KEY", "%pgpSigningKey%") + param("env.PGP_SIGNING_KEY_PASSPHRASE", "%pgpSigningPassphrase%") } buildTypesOrder = arrayListOf( diff --git a/.teamcity/src/main/kotlin/promotion/PublishBranchSnapshotFromQuickFeedback.kt b/.teamcity/src/main/kotlin/promotion/PublishBranchSnapshotFromQuickFeedback.kt index f064a77dd8c6..7963f4f0efd0 100644 --- a/.teamcity/src/main/kotlin/promotion/PublishBranchSnapshotFromQuickFeedback.kt +++ b/.teamcity/src/main/kotlin/promotion/PublishBranchSnapshotFromQuickFeedback.kt @@ -17,12 +17,14 @@ package promotion import jetbrains.buildServer.configs.kotlin.v2019_2.ParameterDisplay +import jetbrains.buildServer.configs.kotlin.v2019_2.RelativeId import vcsroots.gradlePromotionBranches -object PublishBranchSnapshotFromQuickFeedback : PublishGradleDistribution( +object PublishBranchSnapshotFromQuickFeedback : PublishGradleDistributionFullBuild( promotedBranch = "%branch.to.promote%", triggerName = "QuickFeedback", - task = "promoteSnapshot", + prepTask = "prepSnapshot", + promoteTask = "promoteSnapshot", extraParameters = "-PpromotedBranch=%branch.qualifier% ", vcsRootId = gradlePromotionBranches ) { @@ -34,7 +36,7 @@ object PublishBranchSnapshotFromQuickFeedback : PublishGradleDistribution( val triggerName = this.triggerName params { - param("branch.qualifier", "%dep.Gradle_Master_Check_Stage_${triggerName}_Trigger.teamcity.build.branch%") + param("branch.qualifier", "%dep.${RelativeId("Check_Stage_${triggerName}_Trigger")}.teamcity.build.branch%") text( "branch.to.promote", "%branch.qualifier%", diff --git a/.teamcity/src/main/kotlin/promotion/PublishGradleDistribution.kt b/.teamcity/src/main/kotlin/promotion/PublishGradleDistribution.kt deleted file mode 100644 index d6c00bb9984c..000000000000 --- a/.teamcity/src/main/kotlin/promotion/PublishGradleDistribution.kt +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package promotion - -import common.VersionedSettingsBranch -import common.gradleWrapper -import jetbrains.buildServer.configs.kotlin.v2019_2.RelativeId -import vcsroots.gradlePromotionMaster - -abstract class PublishGradleDistribution( - // The branch to be promoted - promotedBranch: String, - task: String, - val triggerName: String, - gitUserName: String = "bot-teamcity", - gitUserEmail: String = "bot-teamcity@gradle.com", - extraParameters: String = "", - vcsRootId: String = gradlePromotionMaster -) : BasePromotionBuildType(vcsRootId) { - - init { - artifactRules = """ - incoming-build-receipt/build-receipt.properties => incoming-build-receipt - **/build/git-checkout/subprojects/base-services/build/generated-resources/build-receipt/org/gradle/build-receipt.properties - **/build/distributions/*.zip => promote-build-distributions - **/build/website-checkout/data/releases.xml - **/build/git-checkout/build/reports/integTest/** => distribution-tests - **/smoke-tests/build/reports/tests/** => post-smoke-tests - """.trimIndent() - - steps { - gradleWrapper { - name = "Promote" - tasks = task - gradleParams = """-PuseBuildReceipt $extraParameters "-PgitUserName=$gitUserName" "-PgitUserEmail=$gitUserEmail" """ - } - } - - params { - password("env.ORG_GRADLE_PROJECT_botGradleGitHubToken", "%github.bot-gradle.token%") - } - - dependencies { - artifacts(RelativeId("Check_Stage_${this@PublishGradleDistribution.triggerName}_Trigger")) { - buildRule = lastSuccessful(promotedBranch) - cleanDestination = true - artifactRules = "build-receipt.properties => incoming-build-receipt/" - } - } - } -} - -fun VersionedSettingsBranch.promoteNightlyTaskName(): String = when (this) { - VersionedSettingsBranch.MASTER -> "promoteNightly" - VersionedSettingsBranch("release") -> "promoteReleaseNightly" - else -> "promotePatchReleaseNightly" -} diff --git a/.teamcity/src/main/kotlin/promotion/PublishGradleDistributionFullBuild.kt b/.teamcity/src/main/kotlin/promotion/PublishGradleDistributionFullBuild.kt new file mode 100644 index 000000000000..0b2dd489ad63 --- /dev/null +++ b/.teamcity/src/main/kotlin/promotion/PublishGradleDistributionFullBuild.kt @@ -0,0 +1,38 @@ +/* + * Copyright 2022 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package promotion + +import vcsroots.gradlePromotionMaster + +abstract class PublishGradleDistributionFullBuild( + // The branch to be promoted + promotedBranch: String, + prepTask: String, + promoteTask: String, + triggerName: String, + gitUserName: String = "bot-teamcity", + gitUserEmail: String = "bot-teamcity@gradle.com", + extraParameters: String = "", + vcsRootId: String = gradlePromotionMaster +) : BasePublishGradleDistribution(promotedBranch, prepTask, triggerName, gitUserName, gitUserEmail, extraParameters, vcsRootId) { + init { + steps { + buildStep(extraParameters, gitUserName, gitUserEmail, triggerName, prepTask, "uploadAll") + buildStep(extraParameters, gitUserName, gitUserEmail, triggerName, prepTask, promoteTask) + } + } +} diff --git a/.teamcity/src/main/kotlin/promotion/PublishNightlySnapshot.kt b/.teamcity/src/main/kotlin/promotion/PublishNightlySnapshot.kt index 930a240ea660..dc35565830a5 100644 --- a/.teamcity/src/main/kotlin/promotion/PublishNightlySnapshot.kt +++ b/.teamcity/src/main/kotlin/promotion/PublishNightlySnapshot.kt @@ -18,11 +18,14 @@ package promotion import common.VersionedSettingsBranch import jetbrains.buildServer.configs.kotlin.v2019_2.triggers.schedule +import vcsroots.gradlePromotionBranches -class PublishNightlySnapshot(branch: VersionedSettingsBranch) : PublishGradleDistribution( +class PublishNightlySnapshot(branch: VersionedSettingsBranch) : PublishGradleDistributionFullBuild( promotedBranch = branch.branchName, - task = branch.promoteNightlyTaskName(), - triggerName = "ReadyforNightly" + prepTask = branch.prepNightlyTaskName(), + promoteTask = branch.promoteNightlyTaskName(), + triggerName = "ReadyforNightly", + vcsRootId = gradlePromotionBranches ) { init { id("Promotion_Nightly") @@ -36,7 +39,13 @@ class PublishNightlySnapshot(branch: VersionedSettingsBranch) : PublishGradleDis this.hour = this@apply } triggerBuild = always() - withPendingChangesOnly = false + withPendingChangesOnly = true + enabled = branch.enableTriggers + // https://www.jetbrains.com/help/teamcity/2022.04/configuring-schedule-triggers.html#general-syntax-1 + // We want it to be triggered only when there're pending changes in the specific vcs root, i.e. GradleMaster/GradleRelease + triggerRules = "+:root=${VersionedSettingsBranch.fromDslContext().vcsRootId()}:." + // The promotion itself will be triggered on gradle-promote's master branch + branchFilter = "+:master" } } } @@ -44,8 +53,8 @@ class PublishNightlySnapshot(branch: VersionedSettingsBranch) : PublishGradleDis } // Avoid two jobs running at the same time and causing troubles -private fun VersionedSettingsBranch.triggeredHour() = when (this.branchName) { - "master" -> 0 - "release" -> 1 +private fun VersionedSettingsBranch.triggeredHour() = when { + isMaster -> 0 + isRelease -> 1 else -> null } diff --git a/.teamcity/src/main/kotlin/promotion/PublishNightlySnapshotFromQuickFeedback.kt b/.teamcity/src/main/kotlin/promotion/PublishNightlySnapshotFromQuickFeedback.kt index 5f89f4c9a6ed..a524e571d67e 100644 --- a/.teamcity/src/main/kotlin/promotion/PublishNightlySnapshotFromQuickFeedback.kt +++ b/.teamcity/src/main/kotlin/promotion/PublishNightlySnapshotFromQuickFeedback.kt @@ -17,11 +17,14 @@ package promotion import common.VersionedSettingsBranch +import vcsroots.gradlePromotionBranches -class PublishNightlySnapshotFromQuickFeedback(branch: VersionedSettingsBranch) : PublishGradleDistribution( +class PublishNightlySnapshotFromQuickFeedback(branch: VersionedSettingsBranch) : PublishGradleDistributionFullBuild( promotedBranch = branch.branchName, - task = branch.promoteNightlyTaskName(), - triggerName = "QuickFeedback" + prepTask = branch.prepNightlyTaskName(), + promoteTask = branch.promoteNightlyTaskName(), + triggerName = "QuickFeedback", + vcsRootId = gradlePromotionBranches ) { init { id("Promotion_SnapshotFromQuickFeedback") diff --git a/.teamcity/src/main/kotlin/promotion/PublishNightlySnapshotFromQuickFeedbackStepCheckReady.kt b/.teamcity/src/main/kotlin/promotion/PublishNightlySnapshotFromQuickFeedbackStepCheckReady.kt new file mode 100644 index 000000000000..cb107d849853 --- /dev/null +++ b/.teamcity/src/main/kotlin/promotion/PublishNightlySnapshotFromQuickFeedbackStepCheckReady.kt @@ -0,0 +1,34 @@ +/* + * Copyright 2022 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package promotion + +import common.VersionedSettingsBranch +import vcsroots.gradlePromotionBranches + +class PublishNightlySnapshotFromQuickFeedbackStepCheckReady(branch: VersionedSettingsBranch) : BasePublishGradleDistribution( + promotedBranch = branch.branchName, + prepTask = branch.prepNightlyTaskName(), + triggerName = "QuickFeedback", + vcsRootId = gradlePromotionBranches, + cleanCheckout = false +) { + init { + id("Promotion_SnapshotFromQuickFeedbackStepCheckReady") + name = "Nightly Snapshot (from QuickFeedback) - Check Ready" + description = "Checks that a nightly snapshot can be published from QuickFeedback" + } +} diff --git a/.teamcity/src/main/kotlin/promotion/PublishNightlySnapshotFromQuickFeedbackStepPromote.kt b/.teamcity/src/main/kotlin/promotion/PublishNightlySnapshotFromQuickFeedbackStepPromote.kt new file mode 100644 index 000000000000..d9815a9d4106 --- /dev/null +++ b/.teamcity/src/main/kotlin/promotion/PublishNightlySnapshotFromQuickFeedbackStepPromote.kt @@ -0,0 +1,45 @@ +/* + * Copyright 2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package promotion + +import common.VersionedSettingsBranch +import vcsroots.gradlePromotionBranches + +class PublishNightlySnapshotFromQuickFeedbackStepPromote(branch: VersionedSettingsBranch) : BasePublishGradleDistribution( + promotedBranch = branch.branchName, + prepTask = branch.prepNightlyTaskName(), + triggerName = "QuickFeedback", + vcsRootId = gradlePromotionBranches, + cleanCheckout = false +) { + init { + id("Promotion_SnapshotFromQuickFeedbackStepPromote") + name = "Nightly Snapshot (from QuickFeedback) - Promote" + description = "Promotes a previously built distribution on this agent on '${branch.branchName}' from Quick Feedback as a new nightly snapshot" + + steps { + buildStep( + this@PublishNightlySnapshotFromQuickFeedbackStepPromote.extraParameters, + this@PublishNightlySnapshotFromQuickFeedbackStepPromote.gitUserName, + this@PublishNightlySnapshotFromQuickFeedbackStepPromote.gitUserEmail, + this@PublishNightlySnapshotFromQuickFeedbackStepPromote.triggerName, + branch.prepNightlyTaskName(), + branch.promoteNightlyTaskName() + ) + } + } +} diff --git a/.teamcity/src/main/kotlin/promotion/PublishNightlySnapshotFromQuickFeedbackStepUpload.kt b/.teamcity/src/main/kotlin/promotion/PublishNightlySnapshotFromQuickFeedbackStepUpload.kt new file mode 100644 index 000000000000..bcd5a6a200d0 --- /dev/null +++ b/.teamcity/src/main/kotlin/promotion/PublishNightlySnapshotFromQuickFeedbackStepUpload.kt @@ -0,0 +1,44 @@ +/* + * Copyright 2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package promotion + +import common.VersionedSettingsBranch +import vcsroots.gradlePromotionBranches + +class PublishNightlySnapshotFromQuickFeedbackStepUpload(branch: VersionedSettingsBranch) : BasePublishGradleDistribution( + promotedBranch = branch.branchName, + prepTask = branch.prepNightlyTaskName(), + triggerName = "QuickFeedback", + vcsRootId = gradlePromotionBranches +) { + init { + id("Promotion_SnapshotFromQuickFeedbackStepUpload") + name = "Nightly Snapshot (from QuickFeedback) - Upload" + description = "Builds and uploads the latest successful changes on '${branch.branchName}' from Quick Feedback as a new distribution" + + steps { + buildStep( + this@PublishNightlySnapshotFromQuickFeedbackStepUpload.extraParameters, + this@PublishNightlySnapshotFromQuickFeedbackStepUpload.gitUserName, + this@PublishNightlySnapshotFromQuickFeedbackStepUpload.gitUserEmail, + this@PublishNightlySnapshotFromQuickFeedbackStepUpload.triggerName, + branch.prepNightlyTaskName(), + "uploadAll" + ) + } + } +} diff --git a/.teamcity/src/main/kotlin/promotion/PublishRelease.kt b/.teamcity/src/main/kotlin/promotion/PublishRelease.kt index 0f14369f8bc0..b0122861a610 100644 --- a/.teamcity/src/main/kotlin/promotion/PublishRelease.kt +++ b/.teamcity/src/main/kotlin/promotion/PublishRelease.kt @@ -20,13 +20,15 @@ import common.VersionedSettingsBranch import jetbrains.buildServer.configs.kotlin.v2019_2.ParameterDisplay abstract class PublishRelease( - task: String, + prepTask: String, + promoteTask: String, requiredConfirmationCode: String, promotedBranch: String, init: PublishRelease.() -> Unit = {} -) : PublishGradleDistribution( +) : PublishGradleDistributionFullBuild( promotedBranch = promotedBranch, - task = task, + prepTask = prepTask, + promoteTask = promoteTask, triggerName = "ReadyforRelease", gitUserEmail = "%gitUserEmail%", gitUserName = "%gitUserName%", @@ -70,7 +72,8 @@ abstract class PublishRelease( class PublishFinalRelease(branch: VersionedSettingsBranch) : PublishRelease( promotedBranch = branch.branchName, - task = "promoteFinalBackportRelease", + prepTask = "prepFinalRelease", + promoteTask = "promoteFinalRelease", requiredConfirmationCode = "final", init = { id("Promotion_FinalRelease") @@ -81,7 +84,8 @@ class PublishFinalRelease(branch: VersionedSettingsBranch) : PublishRelease( class PublishReleaseCandidate(branch: VersionedSettingsBranch) : PublishRelease( promotedBranch = branch.branchName, - task = "promoteRc", + prepTask = "prepRc", + promoteTask = "promoteRc", requiredConfirmationCode = "rc", init = { id("Promotion_ReleaseCandidate") @@ -92,11 +96,12 @@ class PublishReleaseCandidate(branch: VersionedSettingsBranch) : PublishRelease( class PublishMilestone(branch: VersionedSettingsBranch) : PublishRelease( promotedBranch = branch.branchName, - task = "promoteMilestone", + prepTask = "prepMilestone", + promoteTask = branch.promoteMilestoneTaskName(), requiredConfirmationCode = "milestone", init = { id("Promotion_Milestone") name = "Release - Milestone" - description = "Promotes the latest successful change on 'release' as a new milestone" + description = "Promotes the latest successful change on '${branch.branchName}' as a new milestone" } ) diff --git a/.teamcity/src/main/kotlin/promotion/SanityCheck.kt b/.teamcity/src/main/kotlin/promotion/SanityCheck.kt index 3b7f10066caa..128e098275cb 100644 --- a/.teamcity/src/main/kotlin/promotion/SanityCheck.kt +++ b/.teamcity/src/main/kotlin/promotion/SanityCheck.kt @@ -1,6 +1,7 @@ package promotion import common.Os +import common.VersionedSettingsBranch import common.gradleWrapper import common.requiresOs import jetbrains.buildServer.configs.kotlin.v2019_2.BuildType @@ -27,6 +28,7 @@ object SanityCheck : BuildType({ triggers { vcs { branchFilter = "" + enabled = VersionedSettingsBranch.fromDslContext().enableTriggers } } diff --git a/.teamcity/src/main/kotlin/promotion/StartReleaseCycle.kt b/.teamcity/src/main/kotlin/promotion/StartReleaseCycle.kt index 841bd82981ed..66c213082487 100644 --- a/.teamcity/src/main/kotlin/promotion/StartReleaseCycle.kt +++ b/.teamcity/src/main/kotlin/promotion/StartReleaseCycle.kt @@ -27,10 +27,6 @@ object StartReleaseCycle : BasePromotionBuildType(vcsRootId = gradlePromotionMas name = "Start Release Cycle" description = "Promotes a successful build on master as the start of a new release cycle on the release branch" - artifactRules = """ - incoming-build-receipt/build-receipt.properties => incoming-build-receipt - """.trimIndent() - params { text("gitUserEmail", "", label = "Git user.email Configuration", description = "Enter the git 'user.email' configuration to commit change under", display = ParameterDisplay.PROMPT, allowEmpty = true) text("confirmationCode", "", label = "Confirmation Code", description = "Enter the value 'startCycle' (no quotes) to confirm the promotion", display = ParameterDisplay.PROMPT, allowEmpty = false) @@ -42,16 +38,13 @@ object StartReleaseCycle : BasePromotionBuildType(vcsRootId = gradlePromotionMas name = "Promote" tasks = "clean promoteStartReleaseCycle" useGradleWrapper = true - gradleParams = """-PuseBuildReceipt -PconfirmationCode=%confirmationCode% "-PgitUserName=%gitUserName%" "-PgitUserEmail=%gitUserEmail%" """ + gradleParams = """-PcommitId=%dep.${RelativeId("Check_Stage_ReadyforNightly_Trigger")}.build.vcs.number% -PconfirmationCode=%confirmationCode% "-PgitUserName=%gitUserName%" "-PgitUserEmail=%gitUserEmail%" """ param("org.jfrog.artifactory.selectedDeployableServer.defaultModuleVersionConfiguration", "GLOBAL") } } dependencies { - artifacts(RelativeId("Check_Stage_ReadyforNightly_Trigger")) { - buildRule = lastSuccessful("master") - cleanDestination = true - artifactRules = "build-receipt.properties => incoming-build-receipt/" + snapshot(RelativeId("Check_Stage_ReadyforNightly_Trigger")) { } } } diff --git a/.teamcity/src/main/kotlin/promotion/StartReleaseCycleTest.kt b/.teamcity/src/main/kotlin/promotion/StartReleaseCycleTest.kt index e3e2b84e7aaf..e9f6c0273c8e 100644 --- a/.teamcity/src/main/kotlin/promotion/StartReleaseCycleTest.kt +++ b/.teamcity/src/main/kotlin/promotion/StartReleaseCycleTest.kt @@ -16,6 +16,7 @@ package promotion +import common.VersionedSettingsBranch import common.gradleWrapper import jetbrains.buildServer.configs.kotlin.v2019_2.triggers.schedule import jetbrains.buildServer.configs.kotlin.v2019_2.triggers.vcs @@ -32,13 +33,15 @@ object StartReleaseCycleTest : BasePromotionBuildType(vcsRootId = gradlePromotio name = "PromoteTest" tasks = "clean promoteStartReleaseCycle" useGradleWrapper = true - gradleParams = "-PconfirmationCode=startCycle -PtestRun=1" + gradleParams = """-PconfirmationCode=startCycle -PtestRun=1 "-PgitUserName=test" "-PgitUserEmail=test@example.com"""" } } + val enableTriggers = VersionedSettingsBranch.fromDslContext().enableTriggers triggers { vcs { branchFilter = "+:master" + enabled = enableTriggers } schedule { schedulingPolicy = daily { @@ -47,6 +50,7 @@ object StartReleaseCycleTest : BasePromotionBuildType(vcsRootId = gradlePromotio branchFilter = "+:master" triggerBuild = always() withPendingChangesOnly = false + enabled = enableTriggers } } } diff --git a/.teamcity/src/test/kotlin/ApplyDefaultConfigurationTest.kt b/.teamcity/src/test/kotlin/ApplyDefaultConfigurationTest.kt index 8428140755dd..af50750e2542 100644 --- a/.teamcity/src/test/kotlin/ApplyDefaultConfigurationTest.kt +++ b/.teamcity/src/test/kotlin/ApplyDefaultConfigurationTest.kt @@ -48,7 +48,7 @@ class ApplyDefaultConfigurationTest { private val buildModel = CIBuildModel( projectId = "Gradle_Check", - branch = VersionedSettingsBranch.MASTER, + branch = VersionedSettingsBranch("master", true), buildScanTags = listOf("Check"), subprojects = JsonBasedGradleSubprojectProvider(File("../.teamcity/subprojects.json")) ) diff --git a/.teamcity/src/test/kotlin/CIConfigIntegrationTests.kt b/.teamcity/src/test/kotlin/CIConfigIntegrationTests.kt index c09d9d95e4d6..b1ae16d06425 100644 --- a/.teamcity/src/test/kotlin/CIConfigIntegrationTests.kt +++ b/.teamcity/src/test/kotlin/CIConfigIntegrationTests.kt @@ -31,7 +31,7 @@ class CIConfigIntegrationTests { private val subprojectProvider = JsonBasedGradleSubprojectProvider(File("../.teamcity/subprojects.json")) private val model = CIBuildModel( projectId = "Gradle_Check", - branch = VersionedSettingsBranch.MASTER, + branch = VersionedSettingsBranch("master", true), buildScanTags = listOf("Check"), subprojects = subprojectProvider ) diff --git a/.teamcity/src/test/kotlin/PerformanceTestBuildTypeTest.kt b/.teamcity/src/test/kotlin/PerformanceTestBuildTypeTest.kt index 65f0be7f3635..1e363305bda8 100644 --- a/.teamcity/src/test/kotlin/PerformanceTestBuildTypeTest.kt +++ b/.teamcity/src/test/kotlin/PerformanceTestBuildTypeTest.kt @@ -39,7 +39,7 @@ class PerformanceTestBuildTypeTest { private val buildModel = CIBuildModel( projectId = "Gradle_Check", - branch = VersionedSettingsBranch.MASTER, + branch = VersionedSettingsBranch("master", true), buildScanTags = listOf("Check"), subprojects = JsonBasedGradleSubprojectProvider(File("../.teamcity/subprojects.json")) )