Skip to content

Commit d552dba

Browse files
committed
Add snapshot dependency between Build All and Deploy All
Transparent build version configuration
1 parent ccc0231 commit d552dba

File tree

1 file changed

+54
-22
lines changed

1 file changed

+54
-22
lines changed

.teamcity/settings.kts

+54-22
Original file line numberDiff line numberDiff line change
@@ -42,38 +42,62 @@ project {
4242
param("env.JDK_6", "%env.JDK_16%")
4343
}
4444

45-
val buildAll = buildAll()
46-
val builds = platforms.map { build(it) }
45+
val buildVersion = buildVersion()
46+
val buildAll = buildAll(buildVersion)
47+
val builds = platforms.map { build(it, buildVersion) }
4748
builds.forEach { build ->
48-
buildAll.dependsOn(build) {
49-
snapshot {
50-
onDependencyFailure = FailureAction.ADD_PROBLEM
51-
onDependencyCancel = FailureAction.CANCEL
52-
}
53-
}
49+
buildAll.dependsOnSnapshot(build, onFailure = FailureAction.ADD_PROBLEM)
5450
buildAll.dependsOn(build) {
5551
artifacts {
5652
artifactRules = "+:maven=>maven\n+:api=>api"
5753
}
5854
}
5955
}
6056

61-
val deployConfigure = deployConfigure()
57+
val deployConfigure = deployConfigure().apply {
58+
dependsOnSnapshot(buildAll, onFailure = FailureAction.IGNORE)
59+
}
6260
val deploys = platforms.map { deploy(it, deployConfigure) }
6361
val deployPublish = deployPublish(deployConfigure).apply {
62+
dependsOnSnapshot(buildAll, onFailure = FailureAction.IGNORE)
6463
deploys.forEach {
6564
dependsOnSnapshot(it)
6665
}
6766
}
6867

69-
buildTypesOrder = listOf(buildAll) + builds + deployPublish + deployConfigure + deploys
68+
buildTypesOrder = listOf(buildAll, buildVersion, *builds.toTypedArray(), deployPublish, deployConfigure, *deploys.toTypedArray())
7069
}
7170

72-
fun Project.buildAll() = BuildType {
71+
fun Project.buildVersion() = BuildType {
72+
id("Build_Version")
73+
this.name = "Build (Configure Version)"
74+
commonConfigure()
75+
76+
params {
77+
param(versionSuffixParameter, "SNAPSHOT")
78+
param(teamcitySuffixParameter, "%build.counter%")
79+
}
80+
81+
steps {
82+
gradle {
83+
name = "Generate build chain version"
84+
jdkHome = "%env.$jdk%"
85+
tasks = ""
86+
gradleParams = "--info --stacktrace -P$versionSuffixParameter=%$versionSuffixParameter% -P$teamcitySuffixParameter=%$teamcitySuffixParameter%"
87+
buildFile = ""
88+
gradleWrapperPath = ""
89+
}
90+
}
91+
}.also { buildType(it) }
92+
93+
fun Project.buildAll(versionBuild: BuildType) = BuildType {
7394
id("Build_All")
7495
this.name = "Build (All)"
7596
type = BuildTypeSettings.Type.COMPOSITE
76-
97+
98+
dependsOnSnapshot(versionBuild)
99+
buildNumberPattern = versionBuild.depParamRefs.buildNumber.ref
100+
77101
triggers {
78102
vcs {
79103
triggerRules = """
@@ -82,19 +106,27 @@ fun Project.buildAll() = BuildType {
82106
""".trimIndent()
83107
}
84108
}
85-
109+
86110
commonConfigure()
87111
}.also { buildType(it) }
88112

89-
fun Project.build(platform: String) = platform(platform, "Build") {
113+
fun Project.build(platform: String, versionBuild: BuildType) = platform(platform, "Build") {
114+
115+
dependsOnSnapshot(versionBuild)
116+
117+
params {
118+
param(versionSuffixParameter, versionBuild.depParamRefs[versionSuffixParameter].ref)
119+
param(teamcitySuffixParameter, versionBuild.depParamRefs[teamcitySuffixParameter].ref)
120+
}
121+
90122
steps {
91123
gradle {
92124
name = "Build and Test $platform Binaries"
93125
jdkHome = "%env.$jdk%"
94126
jvmArgs = "-Xmx1g"
95127
tasks = "clean publishToBuildLocal check"
96128
// --continue is needed to run tests for all targets even if one target fails
97-
gradleParams = "--info --stacktrace -P$versionSuffixParameter=SNAPSHOT -P$teamcitySuffixParameter=%build.counter% --continue"
129+
gradleParams = "--info --stacktrace -P$versionSuffixParameter=%$versionSuffixParameter% -P$teamcitySuffixParameter=%$teamcitySuffixParameter% --continue"
98130
buildFile = ""
99131
gradleWrapperPath = ""
100132
}
@@ -109,19 +141,19 @@ fun BuildType.dependsOn(build: BuildType, configure: Dependency.() -> Unit) =
109141
dependencies.dependency(build, configure)
110142
}
111143

112-
fun BuildType.dependsOnSnapshot(build: BuildType, configure: SnapshotDependency.() -> Unit = {}) = apply {
144+
fun BuildType.dependsOnSnapshot(build: BuildType, onFailure: FailureAction = FailureAction.FAIL_TO_START, configure: SnapshotDependency.() -> Unit = {}) = apply {
113145
dependencies.dependency(build) {
114146
snapshot {
115147
configure()
116-
onDependencyFailure = FailureAction.FAIL_TO_START
148+
onDependencyFailure = onFailure
117149
onDependencyCancel = FailureAction.CANCEL
118150
}
119151
}
120152
}
121153

122154
fun Project.deployConfigure() = BuildType {
123155
id("Deploy_Configure")
124-
this.name = "Deploy (Configure)"
156+
this.name = "Deploy (Configure Version)"
125157
commonConfigure()
126158

127159
params {
@@ -152,15 +184,15 @@ fun Project.deployPublish(configureBuild: BuildType) = BuildType {
152184
id("Deploy_Publish")
153185
this.name = "Deploy (Publish)"
154186
type = BuildTypeSettings.Type.COMPOSITE
187+
dependsOnSnapshot(configureBuild)
188+
buildNumberPattern = configureBuild.depParamRefs.buildNumber.ref
155189
params {
156-
param(versionSuffixParameter, "${configureBuild.depParamRefs[versionSuffixParameter]}")
157-
158190
// Tell configuration build how to get release version parameter from this build
159191
// "dev" is the default and means publishing is not releasing to public
160-
param(configureBuild.reverseDepParamRefs[releaseVersionParameter].name, "dev")
192+
text(configureBuild.reverseDepParamRefs[releaseVersionParameter].name, "dev", display = ParameterDisplay.PROMPT, label = "Release Version")
161193
}
162194
commonConfigure()
163-
}.also { buildType(it) }.dependsOnSnapshot(configureBuild)
195+
}.also { buildType(it) }
164196

165197

166198
fun Project.deploy(platform: String, configureBuild: BuildType) = platform(platform, "Deploy") {

0 commit comments

Comments
 (0)