Browse Source

Use Gradle Enterprise Conventions Plugin to configure build scans

Closes gh-24512
pull/24518/head
Andy Wilkinson 6 years ago committed by GitHub
parent
commit
d0d8c6e749
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      build.gradle
  2. 90
      gradle/build-scan-user-data.gradle

11
build.gradle

@ -3,6 +3,7 @@ plugins { @@ -3,6 +3,7 @@ plugins {
id 'org.jetbrains.kotlin.jvm' version '1.3.61' apply false
id 'org.jetbrains.dokka' version '0.9.18' apply false
id 'org.asciidoctor.jvm.convert' version '2.4.0'
id 'io.spring.gradle-enterprise-conventions' version '0.0.2'
id 'io.spring.nohttp' version '0.0.4.RELEASE'
id 'de.undercouch.download' version '4.0.0'
id 'com.gradle.build-scan' version '3.1.1'
@ -12,16 +13,6 @@ plugins { @@ -12,16 +13,6 @@ plugins {
}
apply from: "$rootDir/gradle/build-scan-user-data.gradle"
buildScan {
captureTaskInputFiles = true
obfuscation {
ipAddresses { addresses -> addresses.collect { address -> '0.0.0.0'} }
}
publishAlways()
publishIfAuthenticated()
server = 'https://ge.spring.io'
}
ext {
moduleProjects = subprojects.findAll { it.name.startsWith("spring-") }
javaProjects = subprojects - project(":framework-bom")

90
gradle/build-scan-user-data.gradle

@ -1,67 +1,6 @@ @@ -1,67 +1,6 @@
tagOs()
tagIde()
tagCiOrLocal()
addCiMetadata()
addGitMetadata()
addTestTaskMetadata()
addCustomJavaHomeMetadata()
addCustomJavaSourceVersionMetadata()
void tagOs() {
buildScan.tag System.getProperty('os.name')
}
void tagIde() {
if (System.getProperty('idea.version')) {
buildScan.tag 'IntelliJ IDEA'
} else if (System.getProperty('eclipse.buildId')) {
buildScan.tag 'Eclipse'
}
}
void tagCiOrLocal() {
buildScan.tag(isCi() ? 'CI' : 'LOCAL')
}
void addGitMetadata() {
buildScan.background {
def gitCommitId = execAndGetStdout('git', 'rev-parse', '--short=8', '--verify', 'HEAD')
def gitBranchName = execAndGetStdout('git', 'rev-parse', '--abbrev-ref', 'HEAD')
def gitStatus = execAndGetStdout('git', 'status', '--porcelain')
if(gitCommitId) {
def commitIdLabel = 'Git Commit ID'
value commitIdLabel, gitCommitId
link 'Git commit build scans', customValueSearchUrl([(commitIdLabel): gitCommitId])
}
if (gitBranchName) {
tag gitBranchName
value 'Git branch', gitBranchName
}
if (gitStatus) {
tag 'dirty'
value 'Git status', gitStatus
}
}
}
void addCiMetadata() {
def ciBuild = 'CI BUILD'
if (isBamboo()) {
buildScan.link ciBuild, System.getenv('bamboo_resultsUrl')
}
}
void addTestTaskMetadata() {
allprojects {
tasks.withType(Test) { test ->
doFirst {
buildScan.value "Test#maxParallelForks[${test.path}]", test.maxParallelForks.toString()
}
}
}
}
void addCustomJavaHomeMetadata() {
def customJavaHome = System.getProperty("customJavaHome")
if (customJavaHome) {
@ -75,32 +14,3 @@ void addCustomJavaSourceVersionMetadata() { @@ -75,32 +14,3 @@ void addCustomJavaSourceVersionMetadata() {
buildScan.value "Custom Java Source Version", customJavaSourceVersion
}
}
boolean isCi() {
isBamboo()
}
boolean isBamboo() {
System.getenv('bamboo_resultsUrl')
}
String execAndGetStdout(String... args) {
def stdout = new ByteArrayOutputStream()
exec {
commandLine(args)
standardOutput = stdout
}
return stdout.toString().trim()
}
String customValueSearchUrl(Map<String, String> search) {
def query = search.collect { name, value ->
"search.names=${encodeURL(name)}&search.values=${encodeURL(value)}"
}.join('&')
"$buildScan.server/scans?$query"
}
String encodeURL(String url) {
URLEncoder.encode(url, 'UTF-8')
}

Loading…
Cancel
Save