Skip to content

Commit

Permalink
Update tagging plugin (gradle#8800)
Browse files Browse the repository at this point in the history
This PR applies latest tagging plugin (which runs tagging in `GRADLE_RERUN` step) and removes `TAG_BUILD` steps in configurations.
  • Loading branch information
blindpirate authored Mar 20, 2019
1 parent 871dd09 commit 12c09a7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,20 +132,6 @@ fun BaseGradleBuildType.verifyTestFilesCleanupStep(daemon: Boolean = true) {
}
}

private
fun BaseGradleBuildType.tagBuildStep(model: CIBuildModel, daemon: Boolean = true) {
steps {
if (model.tagBuilds) {
gradleWrapper {
name = "TAG_BUILD"
executionMode = BuildStep.ExecutionMode.ALWAYS
tasks = "tagBuild"
gradleParams = "${gradleParameterString(daemon)} -PteamCityUsername=%teamcity.username.restbot% -PteamCityPassword=%teamcity.password.restbot% -PteamCityBuildId=%teamcity.build.id% -PgithubToken=%github.ci.oauth.token%"
}
}
}
}

private
fun BaseGradleBuildType.gradleRunnerStep(model: CIBuildModel, gradleTasks: String, os: Os = Os.linux, extraParameters: String = "", daemon: Boolean = true) {
val buildScanTags = model.buildScanTags + listOfNotNull(stage?.id)
Expand Down Expand Up @@ -174,7 +160,7 @@ fun BaseGradleBuildType.gradleRerunnerStep(model: CIBuildModel, gradleTasks: Str
steps {
gradleWrapper {
name = "GRADLE_RERUNNER"
tasks = gradleTasks
tasks = "$gradleTasks tagBuild"
executionMode = BuildStep.ExecutionMode.RUN_ON_FAILURE
gradleParams = (
listOf(gradleParameterString(daemon)) +
Expand All @@ -184,7 +170,8 @@ fun BaseGradleBuildType.gradleRerunnerStep(model: CIBuildModel, gradleTasks: Str
"-PteamCityPassword=%teamcity.password.restbot%" +
"-PteamCityBuildId=%teamcity.build.id%" +
buildScanTags.map { configurations.buildScanTag(it) } +
"-PonlyPreviousFailedTestClasses=true"
"-PonlyPreviousFailedTestClasses=true" +
"-PgithubToken=%github.ci.oauth.token%"
).joinToString(separator = " ")
}
}
Expand Down Expand Up @@ -213,7 +200,6 @@ fun applyDefaults(model: CIBuildModel, buildType: BaseGradleBuildType, gradleTas

buildType.checkCleanM2Step(os)
buildType.verifyTestFilesCleanupStep(daemon)
buildType.tagBuildStep(model, daemon)

applyDefaultDependencies(model, buildType, notQuick)
}
Expand All @@ -230,7 +216,6 @@ fun applyTestDefaults(model: CIBuildModel, buildType: BaseGradleBuildType, gradl

buildType.checkCleanM2Step(os)
buildType.verifyTestFilesCleanupStep(daemon)
buildType.tagBuildStep(model, daemon)

applyDefaultDependencies(model, buildType, notQuick)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ class ApplyDefaultConfigurationTest {
assertEquals(listOf(
"GRADLE_RUNNER",
"CHECK_CLEAN_M2",
"VERIFY_TEST_FILES_CLEANUP",
"TAG_BUILD"
"VERIFY_TEST_FILES_CLEANUP"
), steps.items.map(BuildStep::name))
assertEquals(expectedRunnerParam(), getGradleStep("GRADLE_RUNNER").gradleParams)
}
Expand All @@ -82,8 +81,7 @@ class ApplyDefaultConfigurationTest {
"GRADLE_RUNNER",
"GRADLE_RERUNNER",
"CHECK_CLEAN_M2",
"VERIFY_TEST_FILES_CLEANUP",
"TAG_BUILD"
"VERIFY_TEST_FILES_CLEANUP"
), steps.items.map(BuildStep::name))
verifyGradleRunnerParams(extraParameters, daemon, expectedDaemonParam)
}
Expand All @@ -104,8 +102,7 @@ class ApplyDefaultConfigurationTest {
"GRADLE_RERUNNER",
"KILL_PROCESSES_STARTED_BY_GRADLE_RERUN",
"CHECK_CLEAN_M2",
"VERIFY_TEST_FILES_CLEANUP",
"TAG_BUILD"
"VERIFY_TEST_FILES_CLEANUP"
), steps.items.map(BuildStep::name))
verifyGradleRunnerParams(extraParameters, daemon, expectedDaemonParam)
}
Expand All @@ -116,9 +113,9 @@ class ApplyDefaultConfigurationTest {
assertEquals(BuildStep.ExecutionMode.RUN_ON_FAILURE, getGradleStep("GRADLE_RERUNNER").executionMode)

assertEquals(expectedRunnerParam(expectedDaemonParam, extraParameters), getGradleStep("GRADLE_RUNNER").gradleParams)
assertEquals(expectedRunnerParam(expectedDaemonParam, extraParameters) + " -PonlyPreviousFailedTestClasses=true", getGradleStep("GRADLE_RERUNNER").gradleParams)
assertEquals(expectedRunnerParam(expectedDaemonParam, extraParameters) + " -PonlyPreviousFailedTestClasses=true -PteamCityBuildId=%teamcity.build.id%", getGradleStep("GRADLE_RERUNNER").gradleParams)
assertEquals("clean myTask", getGradleStep("GRADLE_RUNNER").tasks)
assertEquals("myTask", getGradleStep("GRADLE_RERUNNER").tasks)
assertEquals("myTask tagBuild", getGradleStep("GRADLE_RERUNNER").tasks)
}

private
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ plugins {
// We have to apply it here at the moment, so that when the build scan plugin is auto-applied via --scan can detect that
// the plugin has been already applied. For that the plugin has to be applied with the new plugin DSL syntax.
com.gradle.`build-scan`
id("org.gradle.ci.tag-single-build") version("0.58")
id("org.gradle.ci.tag-single-build") version("0.62")
}

defaultTasks("assemble")
Expand Down

0 comments on commit 12c09a7

Please sign in to comment.