Skip to content

Commit

Permalink
Revert "Make gradle build finished logic CC compatible (elastic#96475)"
Browse files Browse the repository at this point in the history
This reverts commit 841f711.
  • Loading branch information
breskeby committed Nov 10, 2023
1 parent 6407dc2 commit 1736007
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 229 deletions.
7 changes: 0 additions & 7 deletions build-tools-internal/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ gradlePlugin {
id = 'elasticsearch.build'
implementationClass = 'org.elasticsearch.gradle.internal.BuildPlugin'
}
buildFinished {
id = 'elasticsearch.build-finished'
implementationClass = 'org.elasticsearch.gradle.internal.ElasticsearchBuildFinishedPlugin'
}
distro {
id = 'elasticsearch.distro'
implementationClass = 'org.elasticsearch.gradle.internal.distribution.ElasticsearchDistributionPlugin'
Expand Down Expand Up @@ -270,8 +266,6 @@ 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 @@ -286,7 +280,6 @@ 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import org.elasticsearch.gradle.util.GradleUtils

import java.nio.file.Files

String buildNumber = System.getenv('BUILD_NUMBER') ?: System.getenv('BUILDKITE_BUILD_NUMBER')
String performanceTest = System.getenv('BUILD_PERFORMANCE_TEST')
Boolean isNested = System.getProperty("scan.tag.NESTED") != null

if (buildNumber && performanceTest == null && GradleUtils.isIncludedBuild(project) == false && isNested == false) {
def uploadFilePath = "build/${buildNumber}.tar.bz2"
File uploadFile = file(uploadFilePath)
project.gradle.buildFinished { result ->
println "build complete, generating: $uploadFile"
if (uploadFile.exists()) {
project.delete(uploadFile)
}

try {
ant.tar(destfile: uploadFile, compression: "bzip2", longfile: "gnu") {
fileset(dir: projectDir) {
Set<File> fileSet = fileTree(projectDir) {
include("**/*.hprof")
include("**/build/test-results/**/*.xml")
include("**/build/testclusters/**")
include("**/build/testrun/*/temp/**")
include("**/build/**/hs_err_pid*.log")
exclude("**/build/testclusters/**/data/**")
exclude("**/build/testclusters/**/distro/**")
exclude("**/build/testclusters/**/repo/**")
exclude("**/build/testclusters/**/extract/**")
exclude("**/build/testclusters/**/tmp/**")
exclude("**/build/testrun/*/temp/**/data/**")
exclude("**/build/testrun/*/temp/**/distro/**")
exclude("**/build/testrun/*/temp/**/repo/**")
exclude("**/build/testrun/*/temp/**/extract/**")
exclude("**/build/testrun/*/temp/**/tmp/**")
}
.files
.findAll { Files.isRegularFile(it.toPath()) }

if (fileSet.empty) {
// In cases where we don't match any workspace files, exclude everything
ant.exclude(name: "**/*")
} else {
fileSet.each {
ant.include(name: projectDir.toPath().relativize(it.toPath()))
}
}
}

fileset(dir: "${gradle.gradleUserHomeDir}/daemon/${gradle.gradleVersion}", followsymlinks: false) {
include(name: "**/daemon-${ProcessHandle.current().pid()}*.log")
}

fileset(dir: "${gradle.gradleUserHomeDir}/workers", followsymlinks: false)

fileset(dir: "${project.projectDir}/.gradle/reaper", followsymlinks: false, erroronmissingdir: false)
}
} catch (Exception e) {
logger.lifecycle("Failed to archive additional logs", e)
}

if (uploadFile.exists() && System.getenv("BUILDKITE") == "true") {
try {
println "Uploading buildkite artifact: ${uploadFilePath}..."
new ProcessBuilder("buildkite-agent", "artifact", "upload", uploadFilePath)
.start()
.waitFor()

println "Generating buildscan link for artifact..."

def process = new ProcessBuilder("buildkite-agent", "artifact", "search", uploadFilePath, "--step", System.getenv('BUILDKITE_JOB_ID'), "--format", "%i").start()
process.waitFor()
def artifactUuid = (process.text ?: "").trim()

println "Artifact UUID: ${artifactUuid}"
if (artifactUuid) {
buildScan.link 'Artifact Upload', "https://buildkite.com/organizations/elastic/pipelines/${System.getenv('BUILDKITE_PIPELINE_SLUG')}/builds/${buildNumber}/jobs/${System.getenv('BUILDKITE_JOB_ID')}/artifacts/${artifactUuid}"
}
} catch (Exception e) {
logger.lifecycle("Failed to upload buildkite artifact", e)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ buildScan {
}

buildFinished { result ->

buildScanPublished { scan ->
// Attach build scan link as build metadata
// See: https://buildkite.com/docs/pipelines/build-meta-data
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ plugins {
id 'lifecycle-base'
id 'elasticsearch.docker-support'
id 'elasticsearch.global-build-info'
id 'elasticsearch.build-finished'
id 'elasticsearch.build-scan'
id 'elasticsearch.build-complete'
id 'elasticsearch.jdk-download'
id 'elasticsearch.internal-distribution-download'
id 'elasticsearch.runtime-jdk-provision'
Expand Down
1 change: 0 additions & 1 deletion gradle/build.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ commons-codec = "commons-codec:commons-codec:1.11"
commmons-io = "commons-io:commons-io:2.2"
docker-compose = "com.avast.gradle:gradle-docker-compose-plugin:0.17.5"
forbiddenApis = "de.thetaphi:forbiddenapis:3.6"
gradle-enterprise = "com.gradle:gradle-enterprise-gradle-plugin:3.14.1"
hamcrest = "org.hamcrest:hamcrest:2.1"
httpcore = "org.apache.httpcomponents:httpcore:4.4.12"
httpclient = "org.apache.httpcomponents:httpclient:4.5.10"
Expand Down

0 comments on commit 1736007

Please sign in to comment.