Skip to content

Commit

Permalink
Improve build scan tags and values for Jenkins matrix jobs (#50881)
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-vieira committed Jan 10, 2020
1 parent 63472d3 commit 981e4b8
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions gradle/build-scan.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import org.gradle.initialization.BuildRequestMetaData

import java.util.concurrent.TimeUnit


long startTime = project.gradle.services.get(BuildRequestMetaData.class).getStartTime()
long startTime = project.gradle.services.get(BuildRequestMetaData).getStartTime()

buildScan {
URL jenkinsUrl = System.getenv('JENKINS_URL') ? new URL(System.getenv('JENKINS_URL')) : null
Expand All @@ -14,18 +13,14 @@ buildScan {
String nodeName = System.getenv('NODE_NAME')

tag OS.current().name()
if (jobName) {
value 'Job name', jobName
}
if (buildNumber) {
value 'Job number', buildNumber
}

// Automatically publish scans from Elasticsearch CI
if (jenkinsUrl?.host?.endsWith('elastic.co')) {
publishAlways()
buildScan.server = 'https://gradle-enterprise.elastic.co'
}

// Link to Jenkins worker logs and system metrics
if (nodeName) {
link 'System logs', "https://infra-stats.elastic.co/app/infra#/logs?" +
"&logFilter=(expression:'host.name:${nodeName}',kind:kuery)"
Expand All @@ -39,10 +34,26 @@ buildScan {

// Jenkins-specific build scan metadata
if (jenkinsUrl) {
// Parse job name in the case of matrix builds
// Matrix job names come in the form of "base-job-name/matrix_param1=value1,matrix_param2=value2"
def splitJobName = jobName.split('/')
if (splitJobName.length == 2) {
tag splitJobName[0]
tag splitJobName[1]
value 'Job Name', splitJobName[0]
def matrixParams = splitJobName[1].split(',')
matrixParams.collect { it.split('=') }.each { param ->
value "MATRIX_${param[0].toUpperCase()}", param[1]
}
} else {
tag jobName
value 'Job Name', jobName
}

tag 'CI'
tag jobName
link 'Jenkins Build', buildUrl
link 'GCP Upload', "https://console.cloud.google.com/storage/elasticsearch-ci-artifacts/jobs/${jobName}/build/${buildNumber}.tar.bz2"
value 'Job Number', buildNumber

System.getenv().getOrDefault('NODE_LABELS', '').split(' ').each {
value 'Jenkins Worker Label', it
Expand Down

0 comments on commit 981e4b8

Please sign in to comment.