mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 22:57:16 -04:00
[backport 7.x]Move retrieval of Stack version from Gradle's configuration to execution (#13042) (#13066)
The Gradle's configuration of task should be as fast as possible and don't break the build.
This commit moves retrieval of Elastic Stack version from the remote registry to the execution phase of the tasks.
Also the tasks that depends on this has received the same change (downloadEs and check EsSHA), moving from configuration to execution phase.
Close #13030
(cherry picked from commit cef339ce57
)
This commit is contained in:
parent
09bdd51b25
commit
f33522f521
1 changed files with 105 additions and 93 deletions
52
build.gradle
52
build.gradle
|
@ -158,6 +158,9 @@ tasks.register("configureArchitecture") {
|
|||
|
||||
tasks.register("configureArtifactInfo") {
|
||||
dependsOn configureArchitecture
|
||||
description "Set the url to download stack artifacts for select stack version"
|
||||
|
||||
doLast {
|
||||
def versionQualifier = System.getenv('VERSION_QUALIFIER')
|
||||
if (versionQualifier) {
|
||||
version = "$version-$versionQualifier"
|
||||
|
@ -180,6 +183,7 @@ tasks.register("configureArtifactInfo") {
|
|||
project.ext.set("artifactApiVersionedBuildUrl", "${artifactVersionsApi}/${qualifiedVersion}/builds/${stackBuildVersion}")
|
||||
project.ext.set("stackArtifactSuffix", qualifiedVersion)
|
||||
}
|
||||
}
|
||||
|
||||
abstract class SignAliasDefinitionsTask extends DefaultTask {
|
||||
|
||||
|
@ -428,12 +432,15 @@ tasks.register("installIntegrationTestGems") {
|
|||
}
|
||||
}
|
||||
|
||||
tasks.register("downloadFilebeat", Download) {
|
||||
tasks.register("downloadFilebeat") {
|
||||
dependsOn configureArtifactInfo
|
||||
description "Download Filebeat Snapshot for current branch version: ${version}"
|
||||
|
||||
project.ext.set("versionFound", true)
|
||||
inputs.file("${projectDir}/versions.yml")
|
||||
|
||||
doLast {
|
||||
download {
|
||||
String downloadedFilebeatName = "filebeat-${project.ext.get("stackArtifactSuffix")}-${project.ext.get("beatsArchitecture")}"
|
||||
project.ext.set("unpackedFilebeatName", downloadedFilebeatName)
|
||||
|
||||
|
@ -445,14 +452,12 @@ tasks.register("downloadFilebeat", Download) {
|
|||
project.ext.set("filebeatSnapshotUrl", System.getenv("FILEBEAT_SNAPSHOT_URL") ?: buildUrls["package"]["url"])
|
||||
project.ext.set("filebeatDownloadLocation", "${projectDir}/build/${downloadedFilebeatName}.tar.gz")
|
||||
|
||||
|
||||
src project.ext.filebeatSnapshotUrl
|
||||
onlyIfNewer true
|
||||
inputs.file("${projectDir}/versions.yml")
|
||||
outputs.file(project.ext.filebeatDownloadLocation)
|
||||
|
||||
dest new File(project.ext.filebeatDownloadLocation)
|
||||
retries 3
|
||||
doLast {
|
||||
}
|
||||
System.out.println "Downloaded to ${project.ext.filebeatDownloadLocation}"
|
||||
}
|
||||
}
|
||||
|
@ -461,11 +466,13 @@ tasks.register("deleteLocalFilebeat", Delete) {
|
|||
delete ('./build/filebeat')
|
||||
}
|
||||
|
||||
tasks.register("copyFilebeat", Copy){
|
||||
tasks.register("copyFilebeat") {
|
||||
dependsOn = [downloadFilebeat, deleteLocalFilebeat]
|
||||
doLast {
|
||||
copy {
|
||||
from tarTree(resources.gzip(project.ext.filebeatDownloadLocation))
|
||||
into "./build/"
|
||||
doLast {
|
||||
}
|
||||
file("./build/${project.ext.unpackedFilebeatName}").renameTo('./build/filebeat')
|
||||
System.out.println "Unzipped ${project.ext.filebeatDownloadLocation} to ./build/filebeat"
|
||||
System.out.println "Deleting ${project.ext.filebeatDownloadLocation}"
|
||||
|
@ -478,8 +485,9 @@ tasks.register("checkEsSHA") {
|
|||
|
||||
description "Download ES version remote's fingerprint file"
|
||||
|
||||
doLast {
|
||||
String downloadedElasticsearchName = "elasticsearch-${project.ext.get("stackArtifactSuffix")}-${project.ext.get("esArchitecture")}"
|
||||
outputs.file("${projectDir}/build/${downloadedElasticsearchName}.tar.gz.SHA-512")
|
||||
|
||||
|
||||
// find url of build artifact
|
||||
String artifactApiUrl = "${project.ext.get("artifactApiVersionedBuildUrl")}/projects/elasticsearch/packages/${downloadedElasticsearchName}.tar.gz"
|
||||
|
@ -499,22 +507,26 @@ tasks.register("checkEsSHA") {
|
|||
if (localESCalculatedSHA != remoteSHACode) {
|
||||
println "ES package calculated fingerprint is different from remote, deleting local archive"
|
||||
delete(localESArchive)
|
||||
delete(localESCalculatedSHA)
|
||||
}
|
||||
} else {
|
||||
}/* else {
|
||||
mkdir project.buildDir
|
||||
// touch the SHA file else downloadEs task doesn't start, this file his input for the other task
|
||||
new File("${projectDir}/build/${downloadedElasticsearchName}.tar.gz.SHA-512").withWriter { w ->
|
||||
w << "${downloadedElasticsearchName} not yet downloaded"
|
||||
w.close()
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register("downloadEs", Download) {
|
||||
tasks.register("downloadEs") {
|
||||
dependsOn = [configureArtifactInfo, checkEsSHA]
|
||||
description "Download ES Snapshot for current branch version: ${version}"
|
||||
|
||||
inputs.file("${projectDir}/versions.yml")
|
||||
|
||||
doLast {
|
||||
download {
|
||||
String downloadedElasticsearchName = "elasticsearch-${project.ext.get("stackArtifactSuffix")}-${project.ext.get("esArchitecture")}"
|
||||
project.ext.set("unpackedElasticsearchName", "elasticsearch-${project.ext.get("stackArtifactSuffix")}")
|
||||
|
||||
|
@ -529,12 +541,9 @@ tasks.register("downloadEs", Download) {
|
|||
src project.ext.elasticsearchSnapshotURL
|
||||
onlyIfNewer true
|
||||
retries 3
|
||||
inputs.file("${projectDir}/versions.yml")
|
||||
// inputs.file("${projectDir}/build/${downloadedElasticsearchName}.tar.gz.SHA-512")
|
||||
outputs.file(project.ext.elasticsearchDownloadLocation)
|
||||
dest new File(project.ext.elasticsearchDownloadLocation)
|
||||
}
|
||||
|
||||
doLast {
|
||||
System.out.println "Downloaded to ${project.ext.elasticsearchDownloadLocation}"
|
||||
}
|
||||
}
|
||||
|
@ -544,15 +553,18 @@ tasks.register("deleteLocalEs", Delete) {
|
|||
delete ('./build/elasticsearch')
|
||||
}
|
||||
|
||||
tasks.register("copyEs", Copy) {
|
||||
tasks.register("copyEs") {
|
||||
dependsOn = [downloadEs, deleteLocalEs]
|
||||
doLast {
|
||||
println "copyEs executing.."
|
||||
copy {
|
||||
from tarTree(resources.gzip(project.ext.elasticsearchDownloadLocation))
|
||||
into "./build/"
|
||||
doLast {
|
||||
}
|
||||
|
||||
file("./build/${project.ext.unpackedElasticsearchName}").renameTo('./build/elasticsearch')
|
||||
System.out.println "Unzipped ${project.ext.elasticsearchDownloadLocation} to ./build/elasticsearch"
|
||||
System.out.println "Deleting ${project.ext.elasticsearchDownloadLocation}"
|
||||
// delete(project.ext.elasticsearchDownloadLocation)
|
||||
println "Unzipped ${project.ext.elasticsearchDownloadLocation} to ./build/elasticsearch"
|
||||
println "Deleting ${project.ext.elasticsearchDownloadLocation}"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue