Skip to content

Commit

Permalink
Merge branch 'main' into fix-license-version-check
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Nov 21, 2023
2 parents 951ed0e + 49f8446 commit b123bb6
Show file tree
Hide file tree
Showing 155 changed files with 3,943 additions and 3,272 deletions.
83 changes: 22 additions & 61 deletions .ci/init.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ initscript {
}
}

boolean USE_ARTIFACTORY = false

if (System.getenv('VAULT_ADDR') == null) {
// When trying to reproduce errors outside of CI, it can be useful to allow this to just return rather than blowing up
if (System.getenv('CI') == null) {
Expand Down Expand Up @@ -50,75 +48,38 @@ final Vault vault = new Vault(
.engineVersion(1)
.token(vaultToken)
.build()
)
.withRetries(5, 1000)
).withRetries(5, 1000)


if (USE_ARTIFACTORY) {
final Map<String, String> artifactoryCredentials = vault.logical()
.read("${vaultPathPrefix}/artifactory.elstc.co")
.getData()
logger.info("Using elastic artifactory repos")
Closure configCache = {
return {
name "artifactory-gradle-release"
url "https://artifactory.elstc.co/artifactory/gradle-release"
credentials {
username artifactoryCredentials.get("username")
password artifactoryCredentials.get("token")
}
}
}
settingsEvaluated { settings ->
settings.pluginManagement {
repositories {
maven configCache()
}
}
}
projectsLoaded {
allprojects {
buildscript {
repositories {
maven configCache()
}
}
repositories {
maven configCache()
}
}
}
}

gradle.settingsEvaluated { settings ->
settings.pluginManager.withPlugin("com.gradle.enterprise") {
settings.gradleEnterprise {
server = 'https://gradle-enterprise.elastic.co'
}
configureGradleEnterprise(settings)
}
}

void configureGradleEnterprise(def settings) {
settings.gradleEnterprise {
server = 'https://gradle-enterprise.elastic.co'
buildScan.publishAlways()
}

final String buildCacheUrl = System.getProperty('org.elasticsearch.build.cache.url')
final boolean buildCachePush = Boolean.valueOf(System.getProperty('org.elasticsearch.build.cache.push', 'false'))
def isCI = System.getenv("CI") == "true"
settings.buildCache {
local {
// Disable the local build cache in CI since we use ephemeral workers and it incurs an IO penalty
enabled = isCI == false
}
remote(settings.gradleEnterprise.buildCache) {
if (isCI) {
final boolean buildCachePush = Boolean.valueOf(System.getProperty('org.elasticsearch.build.cache.push', 'false'))
final Map<String, String> buildCacheCredentials = System.getenv("GRADLE_BUILD_CACHE_USERNAME") ? [:] : vault.logical()
.read("${vaultPathPrefix}/gradle-build-cache")
.getData()
def username = System.getenv("GRADLE_BUILD_CACHE_USERNAME") ?: buildCacheCredentials.get("username")
def password = System.getenv("GRADLE_BUILD_CACHE_PASSWORD") ?: buildCacheCredentials.get("password")

if (buildCacheUrl) {
final Map<String, String> buildCacheCredentials = System.getenv("GRADLE_BUILD_CACHE_USERNAME") ? [:] : vault.logical()
.read("${vaultPathPrefix}/gradle-build-cache")
.getData()
gradle.settingsEvaluated { settings ->
settings.buildCache {
local {
// Disable the local build cache in CI since we use ephemeral workers and it incurs an IO penalty
enabled = false
}
remote(HttpBuildCache) {
url = buildCacheUrl
push = buildCachePush
credentials {
username = System.getenv("GRADLE_BUILD_CACHE_USERNAME") ?: buildCacheCredentials.get("username")
password = System.getenv("GRADLE_BUILD_CACHE_PASSWORD") ?: buildCacheCredentials.get("password")
}
usernameAndPassword(username, password)
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions build-tools-internal/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ gradlePlugin {
id = 'elasticsearch.build'
implementationClass = 'org.elasticsearch.gradle.internal.BuildPlugin'
}
buildComplete {
id = 'elasticsearch.build-complete'
implementationClass = 'org.elasticsearch.gradle.internal.ElasticsearchBuildCompletePlugin'
}
distro {
id = 'elasticsearch.distro'
implementationClass = 'org.elasticsearch.gradle.internal.distribution.ElasticsearchDistributionPlugin'
Expand Down Expand Up @@ -266,6 +270,8 @@ dependencies {
api buildLibs.apache.rat
api buildLibs.jna
api buildLibs.shadow.plugin
api buildLibs.gradle.enterprise

// for our ide tweaking
api buildLibs.idea.ext
// When upgrading forbidden apis, ensure dependency version is bumped in ThirdPartyPrecommitPlugin as well
Expand All @@ -280,6 +286,7 @@ dependencies {
api buildLibs.asm.tree
api buildLibs.httpclient
api buildLibs.httpcore

compileOnly buildLibs.checkstyle
runtimeOnly "org.elasticsearch.gradle:reaper:$version"
testImplementation buildLibs.checkstyle
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ buildScan {
URL jenkinsUrl = System.getenv('JENKINS_URL') ? new URL(System.getenv('JENKINS_URL')) : null
String buildKiteUrl = System.getenv('BUILDKITE_BUILD_URL') ? System.getenv('BUILDKITE_BUILD_URL') : null

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

background {
tag OS.current().name()
tag Architecture.current().name()
Expand Down Expand Up @@ -132,6 +126,7 @@ buildScan {
}

buildFinished { result ->

buildScanPublished { scan ->
// Attach build scan link as build metadata
// See: https://buildkite.com/docs/pipelines/build-meta-data
Expand Down
12 changes: 9 additions & 3 deletions build-tools-internal/src/main/groovy/elasticsearch.fips.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,15 @@ if (BuildParams.inFipsJvm) {
File fipsSecurity = new File(fipsResourcesDir, javaSecurityFilename)
File fipsPolicy = new File(fipsResourcesDir, 'fips_java.policy')
File fipsTrustStore = new File(fipsResourcesDir, 'cacerts.bcfks')
def bcFips = dependencies.create('org.bouncycastle:bc-fips:1.0.2')
def bcTlsFips = dependencies.create('org.bouncycastle:bctls-fips:1.0.9')

def bcFips = dependencies.create('org.bouncycastle:bc-fips:1.0.2.4')
def bcTlsFips = dependencies.create('org.bouncycastle:bctls-fips:1.0.17')
def manualDebug = false; //change this to manually debug bouncy castle in an IDE
if(manualDebug) {
bcFips = dependencies.create('org.bouncycastle:bc-fips-debug:1.0.2.4')
bcTlsFips = dependencies.create('org.bouncycastle:bctls-fips:1.0.17'){
exclude group: 'org.bouncycastle', module: 'bc-fips' // to avoid jar hell
}
}
pluginManager.withPlugin('java-base') {
TaskProvider<ExportElasticsearchBuildResourcesTask> fipsResourcesTask = project.tasks.register('fipsResources', ExportElasticsearchBuildResourcesTask)
fipsResourcesTask.configure {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ private TaskProvider<LoggedExec> createRunBwcGradleTask(
return getJavaHome(Integer.parseInt(minimumCompilerVersion));
}));

// temporally workaround for reworked gradle enterprise setup
// removed when PR https://github.com/elastic/elasticsearch/pull/102180 backported
// to all BWC branches
loggedExec.getEnvironment().put("BUILDKITE", "false");

if (BuildParams.isCi() && OS.current() != OS.WINDOWS) {
// TODO: Disabled for now until we can figure out why files are getting corrupted
// loggedExec.getEnvironment().put("GRADLE_RO_DEP_CACHE", System.getProperty("user.home") + "/gradle_ro_cache");
Expand Down
Loading

0 comments on commit b123bb6

Please sign in to comment.