Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

2.4 KB
Raw Blame
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

// see globals.gradle
def isCIBuild = System.getenv().keySet().any {it ==~ /(?i)((JENKINS|HUDSON)(_\w+)?|CI)/}

// https://docs.gradle.com/enterprise/gradle-plugin/

develocity {
  server = "https://develocity.apache.org"
  projectId = "solr"

  buildScan {
    uploadInBackground = !isCIBuild

    // Publish on CI (assume key env var set) or locally when opted-in via -Pscan
    def isScanOptIn = providers.gradleProperty('scan').present
    publishing.onlyIf { (isCIBuild || isScanOptIn) && it.authenticated }
    obfuscation {
      ipAddresses {addresses -> addresses.collect {address -> "0.0.0.0"}}
    }

    tag("JDK" + System.getProperty("java.version").find(/\d+/)) // major version
    value("Java Vendor", System.getProperty("java.vendor"))
    value("Java Version", System.getProperty("java.version"))

    // Jenkins job name, less redundant "Solr" parts
    String jenkinsJobName = System.getenv("JOB_NAME")
    if (jenkinsJobName) { // looks like "Solr/Solr-Smoketest-9.5"
      tag(jenkinsJobName.replaceAll(/Solr\W/, "")) // like "Smoketest-9.5"
    }

    // https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables
    if (System.getenv("GITHUB_BASE_REF")) { // only exists for PRs
      tag("PR")
    }
    String ghWorkflowName = System.getenv("GITHUB_WORKFLOW")
    if (ghWorkflowName) {
      tag(ghWorkflowName)
    }
  }
}

buildCache {
  local {
    enabled =
        providers.gradleProperty('org.gradle.caching').map(Boolean::parseBoolean)
            .getOrElse(!isCIBuild)
  }

  remote(develocity.buildCache) {
    enabled = false
  }
}