mirror of
https://github.com/gradle/gradle-build-action.git
synced 2024-12-25 01:56:18 +08:00
Prevent duplicate JSON being written to build-results
This commit is contained in:
parent
a4a9a30e86
commit
0b5047ec4d
@ -84,7 +84,7 @@ def captureUsingBuildFinished(gradle, invocationId) {
|
|||||||
gradle.buildFinished { result ->
|
gradle.buildFinished { result ->
|
||||||
def buildResults = [
|
def buildResults = [
|
||||||
rootProjectName: gradle.rootProject.name,
|
rootProjectName: gradle.rootProject.name,
|
||||||
rootProjectDir: gradle.rootProject.rootDir.absolutePath,
|
rootProjectDir: gradle.rootProject.rootDir.absolutePath,
|
||||||
requestedTasks: gradle.startParameter.taskNames.join(" "),
|
requestedTasks: gradle.startParameter.taskNames.join(" "),
|
||||||
gradleVersion: GradleVersion.current().version,
|
gradleVersion: GradleVersion.current().version,
|
||||||
gradleHomeDir: gradle.gradleHomeDir.absolutePath,
|
gradleHomeDir: gradle.gradleHomeDir.absolutePath,
|
||||||
@ -95,7 +95,10 @@ def captureUsingBuildFinished(gradle, invocationId) {
|
|||||||
def buildResultsDir = new File(System.getenv("RUNNER_TEMP"), ".build-results")
|
def buildResultsDir = new File(System.getenv("RUNNER_TEMP"), ".build-results")
|
||||||
buildResultsDir.mkdirs()
|
buildResultsDir.mkdirs()
|
||||||
def buildResultsFile = new File(buildResultsDir, System.getenv("GITHUB_ACTION") + invocationId + ".json")
|
def buildResultsFile = new File(buildResultsDir, System.getenv("GITHUB_ACTION") + invocationId + ".json")
|
||||||
buildResultsFile << groovy.json.JsonOutput.toJson(buildResults)
|
// Don't overwrite file generated by build-scan plugin if present (which has build-scan-uri)
|
||||||
|
if (!buildResultsFile.exists()) {
|
||||||
|
buildResultsFile << groovy.json.JsonOutput.toJson(buildResults)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,6 +135,7 @@ class TestBuildResultRecorder extends BaseInitScriptTest {
|
|||||||
assert buildResultsDir.listFiles().size() == 1
|
assert buildResultsDir.listFiles().size() == 1
|
||||||
def resultsFile = buildResultsDir.listFiles()[0]
|
def resultsFile = buildResultsDir.listFiles()[0]
|
||||||
assert resultsFile.name.startsWith('github-step-id')
|
assert resultsFile.name.startsWith('github-step-id')
|
||||||
|
assert resultsFile.text.count('rootProjectName') == 1
|
||||||
return resultsFile
|
return resultsFile
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user