2019-07-16 12:34:00 -04:00
|
|
|
import nebula.plugin.info.scm.ScmInfoExtension
|
2019-08-14 16:16:20 -04:00
|
|
|
import org.elasticsearch.gradle.OS
|
2019-07-16 12:34:00 -04:00
|
|
|
|
|
|
|
buildScan {
|
|
|
|
def jenkinsUrl = System.getenv('JENKINS_URL') ? new URL(System.getenv('JENKINS_URL')) : null
|
|
|
|
|
2019-08-14 16:16:20 -04:00
|
|
|
tag OS.current().name()
|
|
|
|
|
2019-07-16 12:34:00 -04:00
|
|
|
// 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
|
|
|
|
}
|
|
|
|
|
2019-08-07 12:04:20 -04:00
|
|
|
def isPrBuild = System.getenv('ROOT_BUILD_CAUSE_GHPRBCAUSE') != null
|
|
|
|
|
2019-07-16 12:34:00 -04:00
|
|
|
// Capture changes included in this CI build except for pull request builds
|
2019-08-07 12:04:20 -04:00
|
|
|
if (System.getenv('GIT_COMMIT') && !isPrBuild) {
|
2019-07-16 12:34:00 -04:00
|
|
|
background {
|
|
|
|
def changes = "git diff --name-only ${System.getenv('GIT_PREVIOUS_COMMIT')}..${System.getenv('GIT_COMMIT')}".execute().text.trim()
|
|
|
|
value 'Git Changes', changes
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-07 12:04:20 -04:00
|
|
|
// Add SCM information
|
|
|
|
if (isPrBuild) {
|
|
|
|
value 'Git Commit ID', System.getenv('ghprbActualCommit')
|
|
|
|
value 'Git Branch', System.getenv('ghprbTargetBranch')
|
|
|
|
tag System.getenv('ghprbTargetBranch')
|
|
|
|
tag "pr/${System.getenv('ghprbPullId')}"
|
|
|
|
link 'Source', "https://github.com/elastic/elasticsearch/tree/${System.getenv('ghprbActualCommit')}"
|
|
|
|
link 'Pull Request', System.getenv('ghprbPullLink')
|
|
|
|
} else {
|
|
|
|
def branch = System.getenv('GIT_BRANCH').split('/').last()
|
|
|
|
value 'Git Commit ID', System.getenv('GIT_COMMIT')
|
|
|
|
value 'Git Branch', branch
|
|
|
|
tag branch
|
|
|
|
link 'Source', "https://github.com/elastic/elasticsearch/tree/${System.getenv('GIT_COMMIT')}"
|
2019-07-16 12:34:00 -04:00
|
|
|
}
|
2019-08-07 12:04:20 -04:00
|
|
|
} else {
|
|
|
|
tag 'LOCAL'
|
2019-07-16 12:34:00 -04:00
|
|
|
}
|
|
|
|
}
|