2019-08-14 16:16:20 -04:00
|
|
|
import org.elasticsearch.gradle.OS
|
2019-07-16 12:34:00 -04:00
|
|
|
|
|
|
|
buildScan {
|
2019-10-18 01:14:46 -04:00
|
|
|
URL jenkinsUrl = System.getenv('JENKINS_URL') ? new URL(System.getenv('JENKINS_URL')) : null
|
|
|
|
String buildNumber = System.getenv('BUILD_NUMBER')
|
2019-10-23 06:27:14 -04:00
|
|
|
String buildUrl = System.getenv('BUILD_URL')
|
2019-10-18 01:14:46 -04:00
|
|
|
String jobName = System.getenv('JOB_NAME')
|
2019-07-16 12:34:00 -04:00
|
|
|
|
2019-08-14 16:16:20 -04:00
|
|
|
tag OS.current().name()
|
2019-10-23 06:27:14 -04:00
|
|
|
if (jobName) {
|
|
|
|
value 'Job name', jobName
|
|
|
|
}
|
|
|
|
if(buildNumber) {
|
|
|
|
value 'Job number', buildNumber
|
|
|
|
}
|
2019-08-14 16:16:20 -04:00
|
|
|
|
2019-10-23 06:27:14 -04:00
|
|
|
if (jenkinsUrl?.host?.endsWith('elastic.co')) {
|
|
|
|
publishAlways()
|
|
|
|
buildScan.server = 'https://gradle-enterprise.elastic.co'
|
2019-07-16 12:34:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Jenkins-specific build scan metadata
|
|
|
|
if (jenkinsUrl) {
|
|
|
|
tag 'CI'
|
2019-10-23 06:27:14 -04:00
|
|
|
tag jobName
|
|
|
|
link 'Jenkins Build', buildUrl
|
|
|
|
link 'GCP Upload', "https://console.cloud.google.com/storage/elasticsearch-ci-artifacts/jobs/${jobName}/build/${buildNumber}.tar.bz2"
|
|
|
|
System.getenv().getOrDefault('NODE_LABELS', '').split(' ').each {
|
2019-07-16 12:34:00 -04:00
|
|
|
value 'Jenkins Worker Label', it
|
|
|
|
}
|
|
|
|
|
2019-08-07 12:04:20 -04:00
|
|
|
// Add SCM information
|
2019-10-23 06:27:14 -04:00
|
|
|
def isPrBuild = System.getenv('ROOT_BUILD_CAUSE_GHPRBCAUSE') != null
|
2019-08-07 12:04:20 -04:00
|
|
|
if (isPrBuild) {
|
|
|
|
value 'Git Commit ID', System.getenv('ghprbActualCommit')
|
|
|
|
value 'Git Branch', System.getenv('ghprbTargetBranch')
|
|
|
|
tag System.getenv('ghprbTargetBranch')
|
|
|
|
tag "pr/${System.getenv('ghprbPullId')}"
|
2019-10-11 18:37:35 -04:00
|
|
|
tag 'pull-request'
|
2019-08-07 12:04:20 -04:00
|
|
|
link 'Source', "https://github.com/elastic/elasticsearch/tree/${System.getenv('ghprbActualCommit')}"
|
|
|
|
link 'Pull Request', System.getenv('ghprbPullLink')
|
|
|
|
} else {
|
2019-10-23 06:27:14 -04:00
|
|
|
if (System.getenv('GIT_BRANCH')) {
|
|
|
|
def branch = System.getenv('GIT_BRANCH').split('/').last()
|
|
|
|
value 'Git Branch', branch
|
|
|
|
tag branch
|
|
|
|
}
|
|
|
|
if (System.getenv('GIT_COMMIT')) {
|
|
|
|
value 'Git Commit ID', System.getenv('GIT_COMMIT')
|
|
|
|
link 'Source', "https://github.com/elastic/elasticsearch/tree/${System.getenv('GIT_COMMIT')}"
|
|
|
|
background {
|
|
|
|
def changes = "git diff --name-only ${System.getenv('GIT_PREVIOUS_COMMIT')}..${System.getenv('GIT_COMMIT')}".execute().text.trim()
|
|
|
|
value 'Git Changes', changes
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
}
|
2019-10-04 01:41:06 -04:00
|
|
|
}
|