|
|
@ -12,168 +12,179 @@ import java.time.LocalDateTime;
|
|
|
|
import org.elasticsearch.gradle.Architecture
|
|
|
|
import org.elasticsearch.gradle.Architecture
|
|
|
|
import org.elasticsearch.gradle.OS
|
|
|
|
import org.elasticsearch.gradle.OS
|
|
|
|
import org.elasticsearch.gradle.internal.info.BuildParams
|
|
|
|
import org.elasticsearch.gradle.internal.info.BuildParams
|
|
|
|
import org.gradle.initialization.BuildRequestMetaData
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
buildScan {
|
|
|
|
import java.lang.management.ManagementFactory
|
|
|
|
URL jenkinsUrl = System.getenv('JENKINS_URL') ? new URL(System.getenv('JENKINS_URL')) : null
|
|
|
|
import java.time.LocalDateTime
|
|
|
|
String buildKiteUrl = System.getenv('BUILDKITE_BUILD_URL') ? System.getenv('BUILDKITE_BUILD_URL') : null
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Automatically publish scans from Elasticsearch CI
|
|
|
|
develocity {
|
|
|
|
if (jenkinsUrl?.host?.endsWith('elastic.co') || jenkinsUrl?.host?.endsWith('elastic.dev') || System.getenv('BUILDKITE') == 'true') {
|
|
|
|
|
|
|
|
publishAlways()
|
|
|
|
|
|
|
|
buildScan.server = 'https://gradle-enterprise.elastic.co'
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
background {
|
|
|
|
buildScan {
|
|
|
|
tag OS.current().name()
|
|
|
|
URL jenkinsUrl = System.getenv('JENKINS_URL') ? new URL(System.getenv('JENKINS_URL')) : null
|
|
|
|
tag Architecture.current().name()
|
|
|
|
String buildKiteUrl = System.getenv('BUILDKITE_BUILD_URL') ? System.getenv('BUILDKITE_BUILD_URL') : null
|
|
|
|
|
|
|
|
|
|
|
|
// Tag if this build is run in FIPS mode
|
|
|
|
// Automatically publish scans from Elasticsearch CI
|
|
|
|
if (BuildParams.inFipsJvm) {
|
|
|
|
if (jenkinsUrl?.host?.endsWith('elastic.co') || jenkinsUrl?.host?.endsWith('elastic.dev') || System.getenv('BUILDKITE') == 'true') {
|
|
|
|
tag 'FIPS'
|
|
|
|
publishing.onlyIf { true }
|
|
|
|
|
|
|
|
server = 'https://gradle-enterprise.elastic.co'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Jenkins-specific build scan metadata
|
|
|
|
|
|
|
|
if (jenkinsUrl) {
|
|
|
|
|
|
|
|
// Disable async upload in CI to ensure scan upload completes before CI agent is terminated
|
|
|
|
|
|
|
|
uploadInBackground = false
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String buildNumber = System.getenv('BUILD_NUMBER')
|
|
|
|
background {
|
|
|
|
String buildUrl = System.getenv('BUILD_URL')
|
|
|
|
tag OS.current().name()
|
|
|
|
String jobName = System.getenv('JOB_NAME')
|
|
|
|
tag Architecture.current().name()
|
|
|
|
String nodeName = System.getenv('NODE_NAME')
|
|
|
|
|
|
|
|
String jobBranch = System.getenv('ghprbTargetBranch') ?: System.getenv('JOB_BRANCH')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Link to Jenkins worker logs and system metrics
|
|
|
|
// Tag if this build is run in FIPS mode
|
|
|
|
if (nodeName) {
|
|
|
|
if (BuildParams.inFipsJvm) {
|
|
|
|
link 'System logs', "https://ci-stats.elastic.co/app/infra#/logs?&logFilter=(expression:'host.name:${nodeName}',kind:kuery)"
|
|
|
|
tag 'FIPS'
|
|
|
|
buildFinished {
|
|
|
|
|
|
|
|
link 'System metrics', "https://ci-stats.elastic.co/app/metrics/detail/host/${nodeName}"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Parse job name in the case of matrix builds
|
|
|
|
// Jenkins-specific build scan metadata
|
|
|
|
// Matrix job names come in the form of "base-job-name/matrix_param1=value1,matrix_param2=value2"
|
|
|
|
if (jenkinsUrl) {
|
|
|
|
def splitJobName = jobName.split('/')
|
|
|
|
// Disable async upload in CI to ensure scan upload completes before CI agent is terminated
|
|
|
|
if (splitJobName.length > 1 && splitJobName.last() ==~ /^([a-zA-Z0-9_\-]+=[a-zA-Z0-9_\-&\.]+,?)+$/) {
|
|
|
|
uploadInBackground = false
|
|
|
|
def baseJobName = splitJobName.dropRight(1).join('/')
|
|
|
|
|
|
|
|
tag baseJobName
|
|
|
|
String buildNumber = System.getenv('BUILD_NUMBER')
|
|
|
|
tag splitJobName.last()
|
|
|
|
String buildUrl = System.getenv('BUILD_URL')
|
|
|
|
value 'Job Name', baseJobName
|
|
|
|
String jobName = System.getenv('JOB_NAME')
|
|
|
|
def matrixParams = splitJobName.last().split(',')
|
|
|
|
String nodeName = System.getenv('NODE_NAME')
|
|
|
|
matrixParams.collect { it.split('=') }.each { param ->
|
|
|
|
String jobBranch = System.getenv('ghprbTargetBranch') ?: System.getenv('JOB_BRANCH')
|
|
|
|
value "MATRIX_${param[0].toUpperCase()}", param[1]
|
|
|
|
|
|
|
|
|
|
|
|
// Link to Jenkins worker logs and system metrics
|
|
|
|
|
|
|
|
if (nodeName) {
|
|
|
|
|
|
|
|
link 'System logs', "https://ci-stats.elastic.co/app/infra#/logs?&logFilter=(expression:'host.name:${nodeName}',kind:kuery)"
|
|
|
|
|
|
|
|
buildFinished {
|
|
|
|
|
|
|
|
link 'System metrics', "https://ci-stats.elastic.co/app/metrics/detail/host/${nodeName}"
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
|
|
|
|
tag jobName
|
|
|
|
// 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 > 1 && splitJobName.last() ==~ /^([a-zA-Z0-9_\-]+=[a-zA-Z0-9_\-&\.]+,?)+$/) {
|
|
|
|
|
|
|
|
def baseJobName = splitJobName.dropRight(1).join('/')
|
|
|
|
|
|
|
|
tag baseJobName
|
|
|
|
|
|
|
|
tag splitJobName.last()
|
|
|
|
|
|
|
|
value 'Job Name', baseJobName
|
|
|
|
|
|
|
|
def matrixParams = splitJobName.last().split(',')
|
|
|
|
|
|
|
|
matrixParams.collect { it.split('=') }.each { param ->
|
|
|
|
|
|
|
|
value "MATRIX_${param[0].toUpperCase()}", param[1]
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
tag jobName
|
|
|
|
|
|
|
|
value 'Job Name', jobName
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tag 'CI'
|
|
|
|
|
|
|
|
link 'CI Build', buildUrl
|
|
|
|
|
|
|
|
link 'GCP Upload',
|
|
|
|
|
|
|
|
"https://console.cloud.google.com/storage/browser/_details/elasticsearch-ci-artifacts/jobs/${URLEncoder.encode(jobName, "UTF-8")}/build/${buildNumber}.tar.bz2"
|
|
|
|
|
|
|
|
value 'Job Number', buildNumber
|
|
|
|
|
|
|
|
if (jobBranch) {
|
|
|
|
|
|
|
|
tag jobBranch
|
|
|
|
|
|
|
|
value 'Git Branch', jobBranch
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
System.getenv().getOrDefault('NODE_LABELS', '').split(' ').each {
|
|
|
|
|
|
|
|
value 'Jenkins Worker Label', it
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Add SCM information
|
|
|
|
|
|
|
|
def isPrBuild = System.getenv('ROOT_BUILD_CAUSE_GHPRBCAUSE') != null
|
|
|
|
|
|
|
|
if (isPrBuild) {
|
|
|
|
|
|
|
|
value 'Git Commit ID', System.getenv('ghprbActualCommit')
|
|
|
|
|
|
|
|
tag "pr/${System.getenv('ghprbPullId')}"
|
|
|
|
|
|
|
|
tag 'pull-request'
|
|
|
|
|
|
|
|
link 'Source', "https://github.com/elastic/elasticsearch/tree/${System.getenv('ghprbActualCommit')}"
|
|
|
|
|
|
|
|
link 'Pull Request', System.getenv('ghprbPullLink')
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
value 'Git Commit ID', BuildParams.gitRevision
|
|
|
|
|
|
|
|
link 'Source', "https://github.com/elastic/elasticsearch/tree/${BuildParams.gitRevision}"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (buildKiteUrl) { //Buildkite-specific build scan metadata
|
|
|
|
|
|
|
|
// Disable async upload in CI to ensure scan upload completes before CI agent is terminated
|
|
|
|
|
|
|
|
uploadInBackground = false
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def branch = System.getenv('BUILDKITE_PULL_REQUEST_BASE_BRANCH') ?: System.getenv('BUILDKITE_BRANCH')
|
|
|
|
|
|
|
|
def repoMatcher = System.getenv('BUILDKITE_REPO') =~ /(https:\/\/github\.com\/|git@github\.com:)(\S+)\.git/
|
|
|
|
|
|
|
|
def repository = repoMatcher.matches() ? repoMatcher.group(2) : "<unknown>"
|
|
|
|
|
|
|
|
def jobLabel = System.getenv('BUILDKITE_LABEL') ?: ''
|
|
|
|
|
|
|
|
def jobName = safeName(jobLabel)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tag 'CI'
|
|
|
|
|
|
|
|
link 'CI Build', "${buildKiteUrl}#${System.getenv('BUILDKITE_JOB_ID')}"
|
|
|
|
|
|
|
|
value 'Job Number', System.getenv('BUILDKITE_BUILD_NUMBER')
|
|
|
|
|
|
|
|
value 'Build ID', System.getenv('BUILDKITE_BUILD_ID')
|
|
|
|
|
|
|
|
value 'Job ID', System.getenv('BUILDKITE_JOB_ID')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
value 'Pipeline', System.getenv('BUILDKITE_PIPELINE_SLUG')
|
|
|
|
|
|
|
|
tag System.getenv('BUILDKITE_PIPELINE_SLUG')
|
|
|
|
|
|
|
|
|
|
|
|
value 'Job Name', jobName
|
|
|
|
value 'Job Name', jobName
|
|
|
|
}
|
|
|
|
tag jobName
|
|
|
|
|
|
|
|
if (jobLabel.contains("/")) {
|
|
|
|
tag 'CI'
|
|
|
|
jobLabel.split("/").collect { safeName(it) }.each { matrix ->
|
|
|
|
link 'CI Build', buildUrl
|
|
|
|
tag matrix
|
|
|
|
link 'GCP Upload', "https://console.cloud.google.com/storage/browser/_details/elasticsearch-ci-artifacts/jobs/${URLEncoder.encode(jobName, "UTF-8")}/build/${buildNumber}.tar.bz2"
|
|
|
|
}
|
|
|
|
value 'Job Number', buildNumber
|
|
|
|
|
|
|
|
if (jobBranch) {
|
|
|
|
|
|
|
|
tag jobBranch
|
|
|
|
|
|
|
|
value 'Git Branch', jobBranch
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
System.getenv().getOrDefault('NODE_LABELS', '').split(' ').each {
|
|
|
|
|
|
|
|
value 'Jenkins Worker Label', it
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Add SCM information
|
|
|
|
|
|
|
|
def isPrBuild = System.getenv('ROOT_BUILD_CAUSE_GHPRBCAUSE') != null
|
|
|
|
|
|
|
|
if (isPrBuild) {
|
|
|
|
|
|
|
|
value 'Git Commit ID', System.getenv('ghprbActualCommit')
|
|
|
|
|
|
|
|
tag "pr/${System.getenv('ghprbPullId')}"
|
|
|
|
|
|
|
|
tag 'pull-request'
|
|
|
|
|
|
|
|
link 'Source', "https://github.com/elastic/elasticsearch/tree/${System.getenv('ghprbActualCommit')}"
|
|
|
|
|
|
|
|
link 'Pull Request', System.getenv('ghprbPullLink')
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
value 'Git Commit ID', BuildParams.gitRevision
|
|
|
|
|
|
|
|
link 'Source', "https://github.com/elastic/elasticsearch/tree/${BuildParams.gitRevision}"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (buildKiteUrl) { //Buildkite-specific build scan metadata
|
|
|
|
|
|
|
|
// Disable async upload in CI to ensure scan upload completes before CI agent is terminated
|
|
|
|
|
|
|
|
uploadInBackground = false
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def branch = System.getenv('BUILDKITE_PULL_REQUEST_BASE_BRANCH') ?: System.getenv('BUILDKITE_BRANCH')
|
|
|
|
|
|
|
|
def repoMatcher = System.getenv('BUILDKITE_REPO') =~ /(https:\/\/github\.com\/|git@github\.com:)(\S+)\.git/
|
|
|
|
|
|
|
|
def repository = repoMatcher.matches() ? repoMatcher.group(2) : "<unknown>"
|
|
|
|
|
|
|
|
def jobLabel = System.getenv('BUILDKITE_LABEL') ?: ''
|
|
|
|
|
|
|
|
def jobName = safeName(jobLabel)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tag 'CI'
|
|
|
|
|
|
|
|
link 'CI Build', "${buildKiteUrl}#${System.getenv('BUILDKITE_JOB_ID')}"
|
|
|
|
|
|
|
|
value 'Job Number', System.getenv('BUILDKITE_BUILD_NUMBER')
|
|
|
|
|
|
|
|
value 'Build ID', System.getenv('BUILDKITE_BUILD_ID')
|
|
|
|
|
|
|
|
value 'Job ID', System.getenv('BUILDKITE_JOB_ID')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
value 'Pipeline', System.getenv('BUILDKITE_PIPELINE_SLUG')
|
|
|
|
|
|
|
|
tag System.getenv('BUILDKITE_PIPELINE_SLUG')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
value 'Job Name', jobName
|
|
|
|
|
|
|
|
tag jobName
|
|
|
|
|
|
|
|
if (jobLabel.contains("/")) {
|
|
|
|
|
|
|
|
jobLabel.split("/").collect {safeName(it) }.each {matrix ->
|
|
|
|
|
|
|
|
tag matrix
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def uptime = ManagementFactory.getRuntimeMXBean().getUptime() / 1000;
|
|
|
|
def uptime = ManagementFactory.getRuntimeMXBean().getUptime() / 1000;
|
|
|
|
def metricsStartTime = LocalDateTime.now().minusSeconds(uptime.longValue()).minusMinutes(15).toString()
|
|
|
|
def metricsStartTime = LocalDateTime.now().minusSeconds(uptime.longValue()).minusMinutes(15).toString()
|
|
|
|
def metricsEndTime = LocalDateTime.now().plusMinutes(15).toString()
|
|
|
|
def metricsEndTime = LocalDateTime.now().plusMinutes(15).toString()
|
|
|
|
|
|
|
|
|
|
|
|
link 'Agent Metrics', "https://es-buildkite-agents.elastic.dev/app/metrics/detail/host/${System.getenv('BUILDKITE_AGENT_NAME')}?_a=(time:(from:%27${metricsStartTime}Z%27,interval:%3E%3D1m,to:%27${metricsEndTime}Z%27))"
|
|
|
|
link 'Agent Metrics',
|
|
|
|
link 'Agent Logs', "https://es-buildkite-agents.elastic.dev/app/logs/stream?logFilter=(filters:!(),query:(language:kuery,query:%27host.name:%20${System.getenv('BUILDKITE_AGENT_NAME')}%27),timeRange:(from:%27${metricsStartTime}Z%27,to:%27${metricsEndTime}Z%27))"
|
|
|
|
"https://es-buildkite-agents.elastic.dev/app/metrics/detail/host/${System.getenv('BUILDKITE_AGENT_NAME')}?_a=(time:(from:%27${metricsStartTime}Z%27,interval:%3E%3D1m,to:%27${metricsEndTime}Z%27))"
|
|
|
|
|
|
|
|
link 'Agent Logs',
|
|
|
|
|
|
|
|
"https://es-buildkite-agents.elastic.dev/app/logs/stream?logFilter=(filters:!(),query:(language:kuery,query:%27host.name:%20${System.getenv('BUILDKITE_AGENT_NAME')}%27),timeRange:(from:%27${metricsStartTime}Z%27,to:%27${metricsEndTime}Z%27))"
|
|
|
|
|
|
|
|
|
|
|
|
if (branch) {
|
|
|
|
if (branch) {
|
|
|
|
tag branch
|
|
|
|
tag branch
|
|
|
|
value 'Git Branch', branch
|
|
|
|
value 'Git Branch', branch
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Add SCM information
|
|
|
|
|
|
|
|
def prId = System.getenv('BUILDKITE_PULL_REQUEST')
|
|
|
|
|
|
|
|
if (prId != 'false') {
|
|
|
|
|
|
|
|
def prBaseUrl = (System.getenv('BUILDKITE_PULL_REQUEST_REPO') - ".git").replaceFirst("git://", "https://")
|
|
|
|
|
|
|
|
value 'Git Commit ID', System.getenv('BUILDKITE_COMMIT')
|
|
|
|
|
|
|
|
tag "pr/${prId}"
|
|
|
|
|
|
|
|
tag 'pull-request'
|
|
|
|
|
|
|
|
link 'Source', "${prBaseUrl}/tree/${System.getenv('BUILDKITE_COMMIT')}"
|
|
|
|
|
|
|
|
link 'Pull Request', "https://github.com/${repository}/pull/${prId}"
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
value 'Git Commit ID', BuildParams.gitRevision
|
|
|
|
|
|
|
|
link 'Source', "https://github.com/${repository}/tree/${BuildParams.gitRevision}"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
buildFinished { result ->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
buildScanPublished { scan ->
|
|
|
|
|
|
|
|
// Attach build scan link as build metadata
|
|
|
|
|
|
|
|
// See: https://buildkite.com/docs/pipelines/build-meta-data
|
|
|
|
|
|
|
|
new ProcessBuilder('buildkite-agent', 'meta-data', 'set', "build-scan-${System.getenv('BUILDKITE_JOB_ID')}", "${scan.buildScanUri}")
|
|
|
|
|
|
|
|
.start()
|
|
|
|
|
|
|
|
.waitFor()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Add a build annotation
|
|
|
|
|
|
|
|
// See: https://buildkite.com/docs/agent/v3/cli-annotate
|
|
|
|
|
|
|
|
def body = """<div class="mb3"><span class="p1 border rounded">${System.getenv('BUILDKITE_LABEL')}</span> :gradle: ${result.failure ? 'failed' : 'successful'} build: <a href="${scan.buildScanUri}"><code>gradle ${gradle.startParameter.taskNames.join(' ')}</code></a></div>"""
|
|
|
|
|
|
|
|
def process = [
|
|
|
|
|
|
|
|
'buildkite-agent',
|
|
|
|
|
|
|
|
'annotate',
|
|
|
|
|
|
|
|
'--context',
|
|
|
|
|
|
|
|
result.failure ? 'gradle-build-scans-failed' : 'gradle-build-scans',
|
|
|
|
|
|
|
|
'--append',
|
|
|
|
|
|
|
|
'--style',
|
|
|
|
|
|
|
|
result.failure ? 'error' : 'info'
|
|
|
|
|
|
|
|
].execute()
|
|
|
|
|
|
|
|
process.withWriter { it.write(body) } // passing the body in as an argument has issues on Windows, so let's use stdin of the process instead
|
|
|
|
|
|
|
|
process.waitFor()
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Add SCM information
|
|
|
|
|
|
|
|
def prId = System.getenv('BUILDKITE_PULL_REQUEST')
|
|
|
|
|
|
|
|
if (prId != 'false') {
|
|
|
|
|
|
|
|
def prBaseUrl = (System.getenv('BUILDKITE_PULL_REQUEST_REPO') - ".git").replaceFirst("git://", "https://")
|
|
|
|
|
|
|
|
value 'Git Commit ID', System.getenv('BUILDKITE_COMMIT')
|
|
|
|
|
|
|
|
tag "pr/${prId}"
|
|
|
|
|
|
|
|
tag 'pull-request'
|
|
|
|
|
|
|
|
link 'Source', "${prBaseUrl}/tree/${System.getenv('BUILDKITE_COMMIT')}"
|
|
|
|
|
|
|
|
link 'Pull Request', "https://github.com/${repository}/pull/${prId}"
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
value 'Git Commit ID', BuildParams.gitRevision
|
|
|
|
|
|
|
|
link 'Source', "https://github.com/${repository}/tree/${BuildParams.gitRevision}"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
buildFinished { result ->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
buildScanPublished { scan
|
|
|
|
|
|
|
|
->
|
|
|
|
|
|
|
|
// Attach build scan link as build metadata
|
|
|
|
|
|
|
|
// See: https://buildkite.com/docs/pipelines/build-meta-data
|
|
|
|
|
|
|
|
new ProcessBuilder('buildkite-agent', 'meta-data', 'set', "build-scan-${System.getenv('BUILDKITE_JOB_ID')}", "${scan.buildScanUri}")
|
|
|
|
|
|
|
|
.start()
|
|
|
|
|
|
|
|
.waitFor()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Add a build annotation
|
|
|
|
|
|
|
|
// See: https://buildkite.com/docs/agent/v3/cli-annotate
|
|
|
|
|
|
|
|
def body = """<div class="mb3"><span class="p1 border rounded">${System.getenv('BUILDKITE_LABEL')}</span> :gradle: ${result.failures ? 'failed' : 'successful'} build: <a href="${scan.buildScanUri}"><code>gradle ${gradle.startParameter.taskNames.join(' ')}</code></a></div>"""
|
|
|
|
|
|
|
|
def process = [
|
|
|
|
|
|
|
|
'buildkite-agent',
|
|
|
|
|
|
|
|
'annotate',
|
|
|
|
|
|
|
|
'--context',
|
|
|
|
|
|
|
|
result.failures ? 'gradle-build-scans-failed' : 'gradle-build-scans',
|
|
|
|
|
|
|
|
'--append',
|
|
|
|
|
|
|
|
'--style',
|
|
|
|
|
|
|
|
result.failures ? 'error' : 'info'
|
|
|
|
|
|
|
|
].execute()
|
|
|
|
|
|
|
|
process.withWriter { it.write(body) }
|
|
|
|
|
|
|
|
// passing the body in as an argument has issues on Windows, so let's use stdin of the process instead
|
|
|
|
|
|
|
|
process.waitFor()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
tag 'LOCAL'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
|
|
|
|
tag 'LOCAL'
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|