mirror of
https://github.com/gradle/gradle-build-action.git
synced 2025-10-21 00:08:55 +08:00
Capture build results when config-cache is enabled
When enabled, the configuration-cache will cause the build to fail when a `buildFinished` listener is added. Instead, use a BuildService to listen for task failures and to write the results on build completion.
This commit is contained in:
@@ -12,9 +12,12 @@ if (isTopLevelBuild) {
|
||||
def atLeastGradle6 = version >= GradleVersion.version("6.0")
|
||||
|
||||
if (atLeastGradle6) {
|
||||
def useBuildService = version >= GradleVersion.version("6.6")
|
||||
settingsEvaluated { settings ->
|
||||
if (settings.pluginManager.hasPlugin("com.gradle.enterprise")) {
|
||||
captureUsingBuildScanPublished(settings.extensions["gradleEnterprise"].buildScan, settings.rootProject.name)
|
||||
} else if (useBuildService) {
|
||||
captureUsingBuildService(settings)
|
||||
} else {
|
||||
captureUsingBuildFinished(gradle)
|
||||
}
|
||||
@@ -30,7 +33,6 @@ if (isTopLevelBuild) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
def captureUsingBuildScanPublished(buildScanExtension, rootProjectName) {
|
||||
buildScanExtension.with {
|
||||
def requestedTasks = gradle.startParameter.taskNames.join(" ")
|
||||
@@ -77,4 +79,8 @@ def captureUsingBuildFinished(gradle) {
|
||||
def buildResultsFile = new File(buildResultsDir, System.getenv("GITHUB_ACTION") + System.currentTimeMillis() + ".json")
|
||||
buildResultsFile << groovy.json.JsonOutput.toJson(buildResults)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def captureUsingBuildService(settings) {
|
||||
apply from: 'build-result-capture-service.plugin.groovy'
|
||||
}
|
||||
|
Reference in New Issue
Block a user