Skip to content

Commit

Permalink
Fix cases where we would unintentionally tar the entire build workspa…
Browse files Browse the repository at this point in the history
…ce (#49130)

Fix cases where we would unintentionally tar the entire build workspace
  • Loading branch information
mark-vieira committed Nov 15, 2019
1 parent 79f504e commit 50139b8
Showing 1 changed file with 28 additions and 28 deletions.
56 changes: 28 additions & 28 deletions gradle/build-complete.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,36 @@ import java.nio.file.Files
String buildNumber = System.getenv('BUILD_NUMBER')

if (buildNumber) {
File uploadFile = file("build/${buildNumber}.tar.bz2")
project.gradle.buildFinished { result ->
println "build complete, generating: $uploadFile"
if (uploadFile.exists()) {
project.delete(uploadFile)
}

try {
ant.tar(destfile: uploadFile, compression: "bzip2", longfile: "gnu") {
fileset(dir: projectDir) {
fileTree(projectDir)
.include("**/*.hprof")
.include("**/reaper.log")
.include("**/build/testclusters/**")
.exclude("**/build/testclusters/**/data/**")
.exclude("**/build/testclusters/**/distro/**")
.exclude("**/build/testclusters/**/repo/**")
.exclude("**/build/testclusters/**/extract/**")
.filter { Files.isRegularFile(it.toPath()) }
.each {
include(name: projectDir.toPath().relativize(it.toPath()))
}
}
File uploadFile = file("build/${buildNumber}.tar.bz2")
project.gradle.buildFinished { result ->
println "build complete, generating: $uploadFile"
if (uploadFile.exists()) {
project.delete(uploadFile)
}

fileset(dir: "${gradle.gradleUserHomeDir}/daemon/${gradle.gradleVersion}", followsymlinks: false) {
include(name: "**/daemon-${ProcessHandle.current().pid()}*.log")
}
try {
ant.tar(destfile: uploadFile, compression: "bzip2", longfile: "gnu") {
fileset(dir: projectDir) {
fileTree(projectDir)
.include("**/*.hprof")
.include("**/reaper.log")
.include("**/build/testclusters/**")
.exclude("**/build/testclusters/**/data/**")
.exclude("**/build/testclusters/**/distro/**")
.exclude("**/build/testclusters/**/repo/**")
.exclude("**/build/testclusters/**/extract/**")
.filter { Files.isRegularFile(it.toPath()) }
.each {
include(name: projectDir.toPath().relativize(it.toPath()))
}
} catch (Exception e) {
logger.lifecycle("Failed to archive additional logs", e)
}

fileset(dir: "${gradle.gradleUserHomeDir}/daemon/${gradle.gradleVersion}", followsymlinks: false) {
include(name: "**/daemon-${ProcessHandle.current().pid()}*.log")
}
}
} catch (Exception e) {
logger.lifecycle("Failed to archive additional logs", e)
}
}
}

0 comments on commit 50139b8

Please sign in to comment.