@@ -51,6 +51,7 @@ import org.logstash.gradle.tooling.ListProjectDependencies
51
51
import org.logstash.gradle.tooling.ExtractBundledJdkVersion
52
52
import org.logstash.gradle.tooling.SignAliasDefinitions
53
53
import org.logstash.gradle.tooling.ToolingUtils
54
+ import org.logstash.gradle.tooling.SnapshotArtifactURLs
54
55
55
56
allprojects {
56
57
group = ' org.logstash'
@@ -174,12 +175,17 @@ tasks.register("configureArtifactInfo") {
174
175
version = " $version -$versionQualifier "
175
176
}
176
177
177
- def isReleaseBuild = System . getenv(' RELEASE' ) == " 1" || versionQualifier
178
+ boolean isReleaseBuild = System . getenv(' RELEASE' ) == " 1" || versionQualifier
178
179
String apiResponse = artifactVersionsApi. toURL(). text
179
180
180
181
def dlVersions = new JsonSlurper (). parseText(apiResponse)
181
182
String qualifiedVersion = dlVersions[' versions' ]. grep(isReleaseBuild ? ~/ ^${version}$/ : ~/ ^${version}-SNAPSHOT/ )[0 ]
182
183
if (qualifiedVersion == null ) {
184
+ if (! isReleaseBuild) {
185
+ project. ext. set(" useProjectSpecificArtifactSnapshotUrl" , true )
186
+ project. ext. set(" stackArtifactSuffix" , " ${ version} -SNAPSHOT" )
187
+ return
188
+ }
183
189
throw new GradleException (" could not find the current artifact from the artifact-api ${ artifactVersionsApi} for ${ version} " )
184
190
}
185
191
// find latest reference to last build
@@ -190,6 +196,7 @@ tasks.register("configureArtifactInfo") {
190
196
191
197
project. ext. set(" artifactApiVersionedBuildUrl" , " ${ artifactVersionsApi} /${ qualifiedVersion} /builds/${ stackBuildVersion} " )
192
198
project. ext. set(" stackArtifactSuffix" , qualifiedVersion)
199
+ project. ext. set(" useProjectSpecificArtifactSnapshotUrl" , false )
193
200
}
194
201
}
195
202
@@ -432,16 +439,23 @@ tasks.register("downloadFilebeat") {
432
439
433
440
doLast {
434
441
download {
435
- String downloadedFilebeatName = " filebeat-${ project.ext.get("stackArtifactSuffix")} -${ project.ext.get("beatsArchitecture")} "
442
+ String beatVersion = project. ext. get(" stackArtifactSuffix" )
443
+ String downloadedFilebeatName = " filebeat-${ beatVersion} -${ project.ext.get("beatsArchitecture")} "
436
444
project. ext. set(" unpackedFilebeatName" , downloadedFilebeatName)
437
445
438
- // find url of build artifact
439
- String artifactApiUrl = " ${ project.ext.get("artifactApiVersionedBuildUrl")} /projects/beats/packages/${ downloadedFilebeatName} .tar.gz"
440
- String apiResponse = artifactApiUrl. toURL(). text
441
- def buildUrls = new JsonSlurper (). parseText(apiResponse)
442
-
443
- project. ext. set(" filebeatSnapshotUrl" , System . getenv(" FILEBEAT_SNAPSHOT_URL" ) ?: buildUrls[" package" ][" url" ])
444
- project. ext. set(" filebeatDownloadLocation" , " ${ projectDir} /build/${ downloadedFilebeatName} .tar.gz" )
446
+ if (project. ext. get(" useProjectSpecificArtifactSnapshotUrl" )) {
447
+ def res = SnapshotArtifactURLs . packageUrls(" beats" , beatVersion, downloadedFilebeatName)
448
+ project. ext. set(" filebeatSnapshotUrl" , System . getenv(" FILEBEAT_SNAPSHOT_URL" ) ?: res. packageUrl)
449
+ project. ext. set(" filebeatDownloadLocation" , " ${ projectDir} /build/${ downloadedFilebeatName} .tar.gz" )
450
+ } else {
451
+ // find url of build artifact
452
+ String artifactApiUrl = " ${ project.ext.get("artifactApiVersionedBuildUrl")} /projects/beats/packages/${ downloadedFilebeatName} .tar.gz"
453
+ String apiResponse = artifactApiUrl. toURL(). text
454
+ def buildUrls = new JsonSlurper (). parseText(apiResponse)
455
+
456
+ project. ext. set(" filebeatSnapshotUrl" , System . getenv(" FILEBEAT_SNAPSHOT_URL" ) ?: buildUrls[" package" ][" url" ])
457
+ project. ext. set(" filebeatDownloadLocation" , " ${ projectDir} /build/${ downloadedFilebeatName} .tar.gz" )
458
+ }
445
459
446
460
src project. ext. filebeatSnapshotUrl
447
461
onlyIfNewer true
@@ -477,14 +491,20 @@ tasks.register("checkEsSHA") {
477
491
description " Download ES version remote's fingerprint file"
478
492
479
493
doLast {
480
- String downloadedElasticsearchName = " elasticsearch-${ project.ext.get("stackArtifactSuffix")} -${ project.ext.get("esArchitecture")} "
481
-
482
-
483
- // find url of build artifact
484
- String artifactApiUrl = " ${ project.ext.get("artifactApiVersionedBuildUrl")} /projects/elasticsearch/packages/${ downloadedElasticsearchName} .tar.gz"
485
- String apiResponse = artifactApiUrl. toURL(). text
486
- def buildUrls = new JsonSlurper (). parseText(apiResponse)
487
- String remoteSHA = buildUrls. package. sha_url. toURL(). text
494
+ String esVersion = project. ext. get(" stackArtifactSuffix" )
495
+ String downloadedElasticsearchName = " elasticsearch-${ esVersion} -${ project.ext.get("esArchitecture")} "
496
+ String remoteSHA
497
+
498
+ if (project. ext. get(" useProjectSpecificArtifactSnapshotUrl" )) {
499
+ def res = SnapshotArtifactURLs . packageUrls(" elasticsearch" , esVersion, downloadedElasticsearchName)
500
+ remoteSHA = res. packageShaUrl
501
+ } else {
502
+ // find url of build artifact
503
+ String artifactApiUrl = " ${ project.ext.get("artifactApiVersionedBuildUrl")} /projects/elasticsearch/packages/${ downloadedElasticsearchName} .tar.gz"
504
+ String apiResponse = artifactApiUrl. toURL(). text
505
+ def buildUrls = new JsonSlurper (). parseText(apiResponse)
506
+ remoteSHA = buildUrls. package. sha_url. toURL(). text
507
+ }
488
508
489
509
def localESArchive = new File (" ${ projectDir} /build/${ downloadedElasticsearchName} .tar.gz" )
490
510
if (localESArchive. exists()) {
@@ -512,22 +532,31 @@ tasks.register("checkEsSHA") {
512
532
513
533
tasks. register(" downloadEs" ) {
514
534
dependsOn = [configureArtifactInfo, checkEsSHA]
515
- description " Download ES Snapshot for current branch version: ${ version} "
516
535
536
+ description " Download ES Snapshot for current branch version: ${ version} "
517
537
inputs. file(" ${ projectDir} /versions.yml" )
518
538
519
539
doLast {
520
540
download {
521
- String downloadedElasticsearchName = " elasticsearch- ${ project.ext.get("stackArtifactSuffix")} - ${ project.ext.get("esArchitecture") } "
522
- project . ext . set( " unpackedElasticsearchName " , " elasticsearch-${ project.ext.get("stackArtifactSuffix ")} " )
541
+ String esVersion = project. ext. get(" stackArtifactSuffix" )
542
+ String downloadedElasticsearchName = " elasticsearch-${ esVersion } - ${ project.ext.get("esArchitecture ")} "
523
543
524
- // find url of build artifact
525
- String artifactApiUrl = " ${ project.ext.get("artifactApiVersionedBuildUrl")} /projects/elasticsearch/packages/${ downloadedElasticsearchName} .tar.gz"
526
- String apiResponse = artifactApiUrl. toURL(). text
527
- def buildUrls = new JsonSlurper (). parseText(apiResponse)
544
+ project. ext. set(" unpackedElasticsearchName" , " elasticsearch-${ esVersion} " )
545
+
546
+ if (project. ext. get(" useProjectSpecificArtifactSnapshotUrl" )) {
547
+ def res = SnapshotArtifactURLs . packageUrls(" elasticsearch" , esVersion, downloadedElasticsearchName)
548
+ project. ext. set(" elasticsearchSnapshotURL" , System . getenv(" ELASTICSEARCH_SNAPSHOT_URL" ) ?: res. packageUrl)
549
+ project. ext. set(" elasticsearchDownloadLocation" , " ${ projectDir} /build/${ downloadedElasticsearchName} .tar.gz" )
550
+ } else {
551
+ // find url of build artifact
552
+ String artifactApiUrl = " ${ project.ext.get("artifactApiVersionedBuildUrl")} /projects/elasticsearch/packages/${ downloadedElasticsearchName} .tar.gz"
553
+ String apiResponse = artifactApiUrl. toURL(). text
528
554
529
- project. ext. set(" elasticsearchSnapshotURL" , System . getenv(" ELASTICSEARCH_SNAPSHOT_URL" ) ?: buildUrls[" package" ][" url" ])
530
- project. ext. set(" elasticsearchDownloadLocation" , " ${ projectDir} /build/${ downloadedElasticsearchName} .tar.gz" )
555
+ def buildUrls = new JsonSlurper (). parseText(apiResponse)
556
+
557
+ project. ext. set(" elasticsearchSnapshotURL" , System . getenv(" ELASTICSEARCH_SNAPSHOT_URL" ) ?: buildUrls[" package" ][" url" ])
558
+ project. ext. set(" elasticsearchDownloadLocation" , " ${ projectDir} /build/${ downloadedElasticsearchName} .tar.gz" )
559
+ }
531
560
532
561
src project. ext. elasticsearchSnapshotURL
533
562
onlyIfNewer true
0 commit comments