Improve build scan metadata (#44247)
(cherry picked from commit 2797b2452b1d3696a4c3a367f21630306da5c818)
This commit is contained in:
parent
2c7ff812da
commit
54194021bf
12
build.gradle
12
build.gradle
|
@ -29,16 +29,13 @@ import org.gradle.util.DistributionLocator
|
||||||
import org.gradle.plugins.ide.eclipse.model.SourceFolder
|
import org.gradle.plugins.ide.eclipse.model.SourceFolder
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id 'com.gradle.build-scan' version '2.2.1'
|
id 'com.gradle.build-scan' version '2.3'
|
||||||
id 'base'
|
id 'base'
|
||||||
id 'elasticsearch.global-build-info'
|
id 'elasticsearch.global-build-info'
|
||||||
}
|
}
|
||||||
if (properties.get("org.elasticsearch.acceptScanTOS", "false") == "true") {
|
|
||||||
buildScan {
|
apply plugin: 'nebula.info-scm'
|
||||||
termsOfServiceUrl = 'https://gradle.com/terms-of-service'
|
apply from: 'gradle/build-scan.gradle'
|
||||||
termsOfServiceAgree = 'yes'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// common maven publishing configuration
|
// common maven publishing configuration
|
||||||
allprojects {
|
allprojects {
|
||||||
|
@ -49,7 +46,6 @@ allprojects {
|
||||||
|
|
||||||
BuildPlugin.configureRepositories(project)
|
BuildPlugin.configureRepositories(project)
|
||||||
|
|
||||||
apply plugin: 'nebula.info-scm'
|
|
||||||
String licenseCommit
|
String licenseCommit
|
||||||
if (VersionProperties.elasticsearch.toString().endsWith('-SNAPSHOT')) {
|
if (VersionProperties.elasticsearch.toString().endsWith('-SNAPSHOT')) {
|
||||||
licenseCommit = scminfo.change ?: "master" // leniency for non git builds
|
licenseCommit = scminfo.change ?: "master" // leniency for non git builds
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
import nebula.plugin.info.scm.ScmInfoExtension
|
||||||
|
|
||||||
|
buildScan {
|
||||||
|
def jenkinsUrl = System.getenv('JENKINS_URL') ? new URL(System.getenv('JENKINS_URL')) : null
|
||||||
|
|
||||||
|
// Accept Gradle ToS when project property org.elasticsearch.acceptScanTOS=true or this is an Elastic CI build
|
||||||
|
if (jenkinsUrl?.host?.endsWith('elastic.co') || Boolean.valueOf(project.findProperty('org.elasticsearch.acceptScanTOS') ?: "false")) {
|
||||||
|
termsOfServiceUrl = 'https://gradle.com/terms-of-service'
|
||||||
|
termsOfServiceAgree = 'yes'
|
||||||
|
}
|
||||||
|
|
||||||
|
// Jenkins-specific build scan metadata
|
||||||
|
if (jenkinsUrl) {
|
||||||
|
tag 'CI'
|
||||||
|
tag System.getenv('JOB_NAME')
|
||||||
|
link 'Jenkins Build', System.getenv('BUILD_URL')
|
||||||
|
System.getenv('NODE_LABELS').split(' ').each {
|
||||||
|
value 'Jenkins Worker Label', it
|
||||||
|
}
|
||||||
|
|
||||||
|
// Capture changes included in this CI build except for pull request builds
|
||||||
|
if (System.getenv('GIT_COMMIT') && System.getenv('ROOT_BUILD_CAUSE_GHPRBCAUSE') == null) {
|
||||||
|
background {
|
||||||
|
def changes = "git diff --name-only ${System.getenv('GIT_PREVIOUS_COMMIT')}..${System.getenv('GIT_COMMIT')}".execute().text.trim()
|
||||||
|
value 'Git Changes', changes
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
tag 'LOCAL'
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add SCM information
|
||||||
|
def scmInfo = project.extensions.findByType(ScmInfoExtension)
|
||||||
|
if (scmInfo && scmInfo.change && scmInfo.branch) {
|
||||||
|
value 'Git Commit ID', scmInfo.change
|
||||||
|
// Don't tag the branch if we are in a detached head state
|
||||||
|
if (scmInfo.branch ==~ /[0-9a-f]{5,40}/ == false) {
|
||||||
|
value 'Git Branch', scmInfo.branch
|
||||||
|
tag scmInfo.branch
|
||||||
|
}
|
||||||
|
link 'Source', "https://github.com/elastic/elasticsearch/commit/${scmInfo.change}"
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue