Skip to content

Commit 6842910

Browse files
committed
Relative paths, jornalctl in additional logs (#48276)
* Relative paths, jornalctl in additional logs This PR fixes the archive generation to preserve the paths relative to the project directory. It also fixes calling journalctl to get the system log. * explicitly remove the file we are building * Skip files locked on windows * Extended readability probe * Try to read the file ahead on windows * Make the tar a best effort * Catch all exceptions
1 parent d31e337 commit 6842910

File tree

1 file changed

+38
-38
lines changed

1 file changed

+38
-38
lines changed

gradle/build-complete.gradle

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -11,49 +11,49 @@ if (buildNumber) {
1111
project.delete(uploadFile)
1212
}
1313

14-
OS.current()
15-
.conditional()
16-
.onUnix {
17-
project.exec {
18-
ignoreExitValue = true
19-
workingDir projectDir
20-
commandLine 'bash', '-c', 'journalctl --since "1 hour ago" 2>&1 > journalctl.log'
21-
}
22-
}
23-
.onWindows {
14+
def isWindows = OS.current() == OS.WINDOWS
15+
if (OS.current() == OS.LINUX) {
16+
project.exec {
17+
ignoreExitValue = true
18+
workingDir projectDir
19+
commandLine 'bash', '-c', 'journalctl --since "1 hour ago" 2>&1 > journalctl.log'
20+
}
21+
}
2422

23+
try {
24+
ant.tar(destfile: uploadFile, compression: "bzip2", longfile: "gnu") {
25+
fileset(dir: projectDir) {
26+
fileTree(projectDir)
27+
.include("**/*.hprof")
28+
.include("**/reaper.log")
29+
.include("**/journalctl.log")
30+
.include("**/build/testclusters/**")
31+
.exclude("**/build/testclusters/**/data/**")
32+
.exclude("**/build/testclusters/**/distro/**")
33+
.exclude("**/build/testclusters/**/repo/**")
34+
.exclude("**/build/testclusters/**/extract/**")
35+
.filter { Files.isRegularFile(it.toPath()) }
36+
.each {
37+
include(name: projectDir.toPath().relativize(it.toPath()))
38+
}
2539
}
26-
.onMac {
2740

41+
fileset(dir: "${gradle.gradleUserHomeDir}/daemon/${gradle.gradleVersion}", followsymlinks: false) {
42+
include(name: "**/daemon-${ProcessHandle.current().pid()}*.log")
2843
}
2944

30-
ant.tar(destfile: uploadFile, compression: "bzip2", longfile: "gnu") {
31-
fileTree(projectDir)
32-
.include("**/*.hprof")
33-
.include("**/reaper.log")
34-
.include("**/journalctl.log")
35-
.include("**/build/testclusters/**")
36-
.exclude("**/build/testclusters/**/data/**")
37-
.exclude("**/build/testclusters/**/distro/**")
38-
.exclude("**/build/testclusters/**/repo/**")
39-
.exclude("**/build/testclusters/**/extract/**")
40-
.filter { Files.isRegularFile(it.toPath()) }
41-
.each { fileset(file: it) }
42-
43-
44-
fileset(dir: "${gradle.gradleUserHomeDir}/daemon/${gradle.gradleVersion}", followsymlinks: false) {
45-
include(name: "**/daemon-${ProcessHandle.current().pid()}*.log")
46-
}
47-
48-
if (Files.isReadable(file("/var/log/").toPath())) {
49-
Files.list(file("/var/log/").toPath())
50-
.filter { it.fileName.endsWith(".log") }
51-
.filter { Files.isReadable(it) }
52-
.filter { Files.isRegularFile(it) }
53-
.forEach {
54-
fileset(file: it)
55-
}
45+
if (Files.isReadable(file("/var/log/").toPath())) {
46+
Files.list(file("/var/log/").toPath())
47+
.filter { it.fileName.endsWith(".log") }
48+
.filter { Files.isReadable(it) }
49+
.filter { Files.isRegularFile(it) }
50+
.forEach {
51+
fileset(file: it)
52+
}
53+
}
5654
}
55+
} catch (Exception e) {
56+
logger.lifecycle("Failed to archive additional logs", e)
5757
}
5858
}
59-
}
59+
}

0 commit comments

Comments
 (0)