Skip to content

Commit

Permalink
Build: Quiet bwc build output (#26430)
Browse files Browse the repository at this point in the history
The output when building bwc versions is currently verbose, with git
warnings from doing git checkout of a hash. This commit changes this to
print the useful info before and after checking out. Note that due to
using LoggedExec, if the git task exits non-zero, the entire output will
still be dumped.
  • Loading branch information
rjernst committed Aug 30, 2017
1 parent 748de60 commit 19417ca
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions distribution/bwc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,11 @@ if (enabled) {
commandLine = ['git', 'clone', rootDir, checkoutDir]
}

// we use regular Exec here to ensure we always get output, regardless of logging level
task findUpstream(type: Exec) {
task findUpstream(type: LoggedExec) {
dependsOn createClone
workingDir = checkoutDir
commandLine = ['git', 'remote', '-v']
ignoreExitValue = true
ByteArrayOutputStream output = new ByteArrayOutputStream()
standardOutput = output
doLast {
if (execResult.exitValue != 0) {
output.toString('UTF-8').eachLine { line -> logger.error(line) }
execResult.assertNormalExitValue()
}
project.ext.upstreamExists = false
output.toString('UTF-8').eachLine {
if (it.contains("upstream")) {
Expand All @@ -107,13 +99,15 @@ if (enabled) {
commandLine = ['git', 'fetch', '--all']
}

// this is an Exec task so that the SHA that is checked out is logged
String buildMetadataKey = "bwc_refspec_${project.path.substring(1)}"
task checkoutBwcBranch(type: Exec) {
def String refspec = System.getProperty("tests.bwc.refspec", buildMetadata.get(buildMetadataKey, "upstream/${bwcBranch}"))
task checkoutBwcBranch(type: LoggedExec) {
String refspec = System.getProperty("tests.bwc.refspec", buildMetadata.get(buildMetadataKey, "upstream/${bwcBranch}"))
dependsOn fetchLatest
workingDir = checkoutDir
commandLine = ['git', 'checkout', refspec]
doFirst {
println "Checking out elasticsearch ${refspec} for branch ${bwcBranch}"
}
}

File buildMetadataFile = project.file("build/${project.name}/build_metadata")
Expand All @@ -130,7 +124,9 @@ if (enabled) {
execResult.assertNormalExitValue()
}
project.mkdir(buildMetadataFile.parent)
buildMetadataFile.setText("${buildMetadataKey}=${output.toString('UTF-8')}", 'UTF-8')
String commit = output.toString('UTF-8')
buildMetadataFile.setText("${buildMetadataKey}=${commit}", 'UTF-8')
println "Checked out elasticsearch commit ${commit}"
}
}

Expand All @@ -143,7 +139,6 @@ if (enabled) {
tasks = [':distribution:deb:assemble', ':distribution:rpm:assemble', ':distribution:zip:assemble']
}


artifacts {
'default' file: bwcDeb, name: 'elasticsearch', type: 'deb', builtBy: buildBwcVersion
'default' file: bwcRpm, name: 'elasticsearch', type: 'rpm', builtBy: buildBwcVersion
Expand Down

0 comments on commit 19417ca

Please sign in to comment.