mirror of
https://github.com/gradle/gradle-build-action.git
synced 2024-12-26 01:56:18 +08:00
parent
dc5927259f
commit
77699bae74
@ -51,11 +51,15 @@ abstract class BuildResultsRecorder implements BuildService<BuildResultsRecorder
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
def buildResultsDir = new File(runnerTempDir, ".build-results")
|
try {
|
||||||
buildResultsDir.mkdirs()
|
def buildResultsDir = new File(runnerTempDir, ".build-results")
|
||||||
def buildResultsFile = new File(buildResultsDir, githubActionStep + getParameters().getInvocationId().get() + ".json")
|
buildResultsDir.mkdirs()
|
||||||
if (!buildResultsFile.exists()) {
|
def buildResultsFile = new File(buildResultsDir, githubActionStep + getParameters().getInvocationId().get() + ".json")
|
||||||
buildResultsFile << groovy.json.JsonOutput.toJson(buildResults)
|
if (!buildResultsFile.exists()) {
|
||||||
|
buildResultsFile << groovy.json.JsonOutput.toJson(buildResults)
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
println "\ngradle-build-action failed to write build-results file. Will continue.\n> ${e.getLocalizedMessage()}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -122,17 +122,22 @@ class BuildResults {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
def buildResultsDir = new File(runnerTempDir, ".build-results")
|
try {
|
||||||
buildResultsDir.mkdirs()
|
def buildResultsDir = new File(runnerTempDir, ".build-results")
|
||||||
def buildResultsFile = new File(buildResultsDir, githubActionStep + invocationId + ".json")
|
buildResultsDir.mkdirs()
|
||||||
|
def buildResultsFile = new File(buildResultsDir, githubActionStep + invocationId + ".json")
|
||||||
|
|
||||||
// Overwrite any contents written by buildFinished or build service, since this result is a superset.
|
// Overwrite any contents written by buildFinished or build service, since this result is a superset.
|
||||||
if (buildResultsFile.exists()) {
|
if (buildResultsFile.exists()) {
|
||||||
if (overwrite) {
|
if (overwrite) {
|
||||||
buildResultsFile.text = groovy.json.JsonOutput.toJson(buildResults)
|
buildResultsFile.text = groovy.json.JsonOutput.toJson(buildResults)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
buildResultsFile << groovy.json.JsonOutput.toJson(buildResults)
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
buildResultsFile << groovy.json.JsonOutput.toJson(buildResults)
|
} catch (Exception e) {
|
||||||
|
println "\ngradle-build-action failed to write build-results file. Will continue.\n> ${e.getLocalizedMessage()}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -148,6 +148,23 @@ class TestBuildResultRecorder extends BaseInitScriptTest {
|
|||||||
testGradleVersion << ALL_VERSIONS
|
testGradleVersion << ALL_VERSIONS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def "produces no build results file when RUNNER_TEMP dir is not a writable directory with #testGradleVersion"() {
|
||||||
|
assumeTrue testGradleVersion.compatibleWithCurrentJvm
|
||||||
|
|
||||||
|
when:
|
||||||
|
def invalidDir = new File(testProjectDir, 'invalid-runner-temp')
|
||||||
|
invalidDir.createNewFile()
|
||||||
|
|
||||||
|
run(['help'], initScript, testGradleVersion.gradleVersion, [], [RUNNER_TEMP: invalidDir.absolutePath])
|
||||||
|
|
||||||
|
then:
|
||||||
|
def buildResultsDir = new File(testProjectDir, '.build-results')
|
||||||
|
assert !buildResultsDir.exists()
|
||||||
|
|
||||||
|
where:
|
||||||
|
testGradleVersion << ALL_VERSIONS
|
||||||
|
}
|
||||||
|
|
||||||
def "produces build results file with build scan when GE plugin is applied in settingsEvaluated"() {
|
def "produces build results file with build scan when GE plugin is applied in settingsEvaluated"() {
|
||||||
assumeTrue testGradleVersion.compatibleWithCurrentJvm
|
assumeTrue testGradleVersion.compatibleWithCurrentJvm
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user