Skip to content

Commit

Permalink
download exact version artifact for release build otherwise download …
Browse files Browse the repository at this point in the history
…snapshot (elastic#10664)
  • Loading branch information
colinsurprenant authored and jsvd committed Apr 11, 2019
1 parent aa03eb3 commit a121ee4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ def versionQualifier = System.getenv('VERSION_QUALIFIER')
if (versionQualifier) {
version = "$version-$versionQualifier"
}
// a release build will try to download the exact version artifact and not append -SNAPSHOT to it see
// the downloadEs task below
def isReleaseBuild = System.getenv('RELEASE') == "1" || versionQualifier

// Tasks

Expand Down Expand Up @@ -330,7 +333,7 @@ task downloadEs(type: Download) {

doFirst {
if (!project.ext.versionFound) {
throw new GradleException("could not find the current artifact from the artifact-api ${artifactsVersionApi} for version: ${version}")
throw new GradleException("could not find the current artifact from the artifact-api ${artifactsVersionApi} for " + (isReleaseBuild ? "release" : "snapshot") + " version: ${version}")
}
}

Expand All @@ -340,7 +343,9 @@ task downloadEs(type: Download) {
// in the normal PR type builds it is plain '7.0.0'
// in the build invoked by the release manager it is '7.0.0-alpha1' etc.
// the artifacts-api will return JSON like this: `{"versions":["5.6.13-SNAPSHOT","6.4.3-SNAPSHOT","6.5.0-SNAPSHOT","6.6.0-SNAPSHOT","7.0.0-alpha1-SNAPSHOT"]}`
String qualifiedVersion = dlVersions['versions'].grep(~/^${version}.*/)[0]

String qualifiedVersion = dlVersions['versions'].grep(isReleaseBuild ? ~/^${version}$/ : ~/^${version}-SNAPSHOT/)[0]

if (qualifiedVersion == null) {
// the version is not found in the versions API, for now just set dummy values so the
// task parameters like src and dest below sees these dummy values but also set
Expand Down

0 comments on commit a121ee4

Please sign in to comment.