forked from opensearch-project/OpenSearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create an upload report once the build completes (#47642)
* Create an upload report once the build completes We used to have this logic in Jenkins, but that forced us to make it platform dependent and gave us less control on what to include here. With this change we create a single archive to be uploaded after the build completes, and we include a link in the build scan to where we know this should get uploaded. * Fix when there's nothign to upload * Log the directory size * Switch to ant to walk the project tree * Collect journlas * Filter for regular files * only call journalctl on unix where we have bash * Grab only logs fro this gradle version * restrict demon log to relevant one
- Loading branch information
Showing
3 changed files
with
65 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import java.nio.file.Files | ||
import org.elasticsearch.gradle.OS | ||
|
||
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) | ||
} | ||
|
||
OS.current() | ||
.conditional() | ||
.onUnix { | ||
project.exec { | ||
ignoreExitValue = true | ||
workingDir projectDir | ||
commandLine 'bash', '-c', 'journalctl --since "1 hour ago" 2>&1 > journalctl.log' | ||
} | ||
} | ||
.onWindows { | ||
|
||
} | ||
.onMac { | ||
|
||
} | ||
|
||
ant.tar(destfile: uploadFile, compression: "bzip2", longfile: "gnu") { | ||
fileTree(projectDir) | ||
.include("**/*.hprof") | ||
.include("**/reaper.log") | ||
.include("**/journalctl.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 { fileset(file: it) } | ||
|
||
|
||
fileset(dir: "${gradle.gradleUserHomeDir}/daemon/${gradle.gradleVersion}", followsymlinks: false) { | ||
include(name: "**/daemon-${ProcessHandle.current().pid()}*.log") | ||
} | ||
|
||
if (Files.isReadable(file("/var/log/").toPath())) { | ||
Files.list(file("/var/log/").toPath()) | ||
.filter { it.fileName.endsWith(".log") } | ||
.filter { Files.isReadable(it) } | ||
.filter { Files.isRegularFile(it) } | ||
.forEach { | ||
fileset(file: it) | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters