"Fossies" - the Fresh Open Source Software Archive

Member "elasticsearch-6.8.15/gradle/build-scan.gradle" (3 Mar 2021, 3600 Bytes) of package /linux/www/elasticsearch-6.8.15-src.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Java source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "build-scan.gradle": 6.8.14_vs_6.8.15.

    1 import org.gradle.initialization.BuildRequestMetaData
    2 
    3 import java.util.concurrent.TimeUnit
    4 
    5 long startTime = project.gradle.services.get(BuildRequestMetaData).getStartTime()
    6 
    7 buildScan {
    8   URL jenkinsUrl = System.getenv('JENKINS_URL') ? new URL(System.getenv('JENKINS_URL')) : null
    9   String buildNumber = System.getenv('BUILD_NUMBER')
   10   String buildUrl = System.getenv('BUILD_URL')
   11   String jobName = System.getenv('JOB_NAME')
   12   String nodeName = System.getenv('NODE_NAME')
   13 
   14   // Automatically publish scans from Elasticsearch CI
   15   if (jenkinsUrl?.host?.endsWith('elastic.co')) {
   16     publishAlways()
   17     buildScan.server = 'https://gradle-enterprise.elastic.co'
   18   }
   19 
   20   // Link to Jenkins worker logs and system metrics
   21   if (nodeName) {
   22     link 'System logs', "https://infra-stats.elastic.co/app/infra#/logs?" +
   23       "&logFilter=(expression:'host.name:${nodeName}',kind:kuery)"
   24     buildFinished {
   25       link 'System metrics', "https://infra-stats.elastic.co/app/infra#/metrics/host/" +
   26         "${nodeName}?_g=()&metricTime=(autoReload:!f,refreshInterval:5000," +
   27         "time:(from:${startTime - TimeUnit.MILLISECONDS.convert(5, TimeUnit.MINUTES)},interval:%3E%3D1m," +
   28         "to:${System.currentTimeMillis() + TimeUnit.MILLISECONDS.convert(5, TimeUnit.MINUTES)}))"
   29     }
   30   }
   31 
   32   // Jenkins-specific build scan metadata
   33   if (jenkinsUrl) {
   34     // Parse job name in the case of matrix builds
   35     // Matrix job names come in the form of "base-job-name/matrix_param1=value1,matrix_param2=value2"
   36     def splitJobName = jobName.split('/')
   37     if (splitJobName.length > 1 && splitJobName.last() ==~ /^([a-zA-Z0-9_\-]+=[a-zA-Z0-9_\-&\.]+,?)+$/) {
   38       def baseJobName = splitJobName.dropRight(1).join('/')
   39       tag baseJobName
   40       tag splitJobName.last()
   41       value 'Job Name', baseJobName
   42       def matrixParams = splitJobName.last().split(',')
   43       matrixParams.collect { it.split('=') }.each { param ->
   44         value "MATRIX_${param[0].toUpperCase()}", param[1]
   45       }
   46     } else {
   47       tag jobName
   48       value 'Job Name', jobName
   49     }
   50 
   51     tag 'CI'
   52     link 'CI Build', buildUrl
   53     link 'GCP Upload', "https://console.cloud.google.com/storage/browser/_details/elasticsearch-ci-artifacts/jobs/${URLEncoder.encode(jobName, "UTF-8")}/build/${buildNumber}.tar.bz2"
   54     value 'Job Number', buildNumber
   55 
   56     System.getenv().getOrDefault('NODE_LABELS', '').split(' ').each {
   57       value 'Jenkins Worker Label', it
   58     }
   59 
   60     // Add SCM information
   61     def isPrBuild = System.getenv('ROOT_BUILD_CAUSE_GHPRBCAUSE') != null
   62     if (isPrBuild) {
   63       value 'Git Commit ID', System.getenv('ghprbActualCommit')
   64       value 'Git Branch', System.getenv('ghprbTargetBranch')
   65       tag System.getenv('ghprbTargetBranch')
   66       tag "pr/${System.getenv('ghprbPullId')}"
   67       tag 'pull-request'
   68       link 'Source', "https://github.com/elastic/elasticsearch/tree/${System.getenv('ghprbActualCommit')}"
   69       link 'Pull Request', System.getenv('ghprbPullLink')
   70     } else {
   71       if (System.getenv('GIT_BRANCH')) {
   72         def branch = System.getenv('GIT_BRANCH').split('/').last()
   73         value 'Git Branch', branch
   74         tag branch
   75       }
   76       if (System.getenv('GIT_COMMIT')) {
   77         value 'Git Commit ID', System.getenv('GIT_COMMIT')
   78         link 'Source', "https://github.com/elastic/elasticsearch/tree/${System.getenv('GIT_COMMIT')}"
   79         background {
   80           def changes = "git diff --name-only ${System.getenv('GIT_PREVIOUS_COMMIT')}..${System.getenv('GIT_COMMIT')}".execute().text.trim()
   81           value 'Git Changes', changes
   82         }
   83       }
   84     }
   85   } else {
   86     tag 'LOCAL'
   87   }
   88 }