From 73b959971eb946c804306ff044a7b780e8a31118 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 1 Sep 2020 17:23:40 +0100 Subject: [PATCH 1/4] [packaging] Normalise GCP bucket folder structure --- .ci/packaging.groovy | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/.ci/packaging.groovy b/.ci/packaging.groovy index 4005e23eb2a9..ea36bf58afe1 100644 --- a/.ci/packaging.groovy +++ b/.ci/packaging.groovy @@ -230,11 +230,11 @@ def withMacOSEnv(Closure body){ def publishPackages(baseDir){ def bucketUri = "gs://${JOB_GCS_BUCKET}/snapshots" - if (env.CHANGE_ID?.trim()) { + if (isPR()) { bucketUri = "gs://${JOB_GCS_BUCKET}/pull-requests/pr-${env.CHANGE_ID}" } - - googleStorageUpload(bucket: "${bucketUri}", + def beatsFolderName = getBeatsName(baseDir) + googleStorageUpload(bucket: "${bucketUri}/${beatsFolderName}", credentialsId: "${JOB_GCS_CREDENTIALS}", pathPrefix: "${baseDir}/build/distributions/", pattern: "${baseDir}/build/distributions/**/*", @@ -243,6 +243,19 @@ def publishPackages(baseDir){ ) } +/** +* There is a specific folder structure in https://staging.elastic.co/ and https://artifacts.elastic.co/downloads/ +* therefore the storage bucket in GCP should follow the same folder structure. +* This is required by https://github.com/elastic/beats-tester +*/ +def getBeatsName(baseDir) { + def beatsFolderName = baseDir + if (baseDir.split('/')) { + beatsFolderName = baseDir.split('')[1] + } + return beatsFolderName +} + def withBeatsEnv(Closure body) { withMageEnv(){ withEnv([ From e7c3e913bc4b347d5c705f3a098ab1903071a91c Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Wed, 2 Sep 2020 09:01:08 +0100 Subject: [PATCH 2/4] Fix quoted path separator --- .ci/packaging.groovy | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.ci/packaging.groovy b/.ci/packaging.groovy index ea36bf58afe1..fd2c3e9c5424 100644 --- a/.ci/packaging.groovy +++ b/.ci/packaging.groovy @@ -249,9 +249,10 @@ def publishPackages(baseDir){ * This is required by https://github.com/elastic/beats-tester */ def getBeatsName(baseDir) { - def beatsFolderName = baseDir - if (baseDir.split('/')) { - beatsFolderName = baseDir.split('')[1] + def PATH_SEPARATOR_QUOTED = '\\/' + def beatsFolderName = baseDir.replaceAll(PATH_SEPARATOR_QUOTED, '') + if (baseDir.split(PATH_SEPARATOR_QUOTED).length > 1) { + beatsFolderName = baseDir.split(PATH_SEPARATOR_QUOTED)[1] } return beatsFolderName } From c2db9a66a577131248f5b593b780ff1d23cdf293 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Wed, 2 Sep 2020 13:11:23 +0100 Subject: [PATCH 3/4] Update .ci/packaging.groovy Co-authored-by: Ivan Fernandez Calvo --- .ci/packaging.groovy | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.ci/packaging.groovy b/.ci/packaging.groovy index fd2c3e9c5424..13c5d044bb4a 100644 --- a/.ci/packaging.groovy +++ b/.ci/packaging.groovy @@ -249,12 +249,7 @@ def publishPackages(baseDir){ * This is required by https://github.com/elastic/beats-tester */ def getBeatsName(baseDir) { - def PATH_SEPARATOR_QUOTED = '\\/' - def beatsFolderName = baseDir.replaceAll(PATH_SEPARATOR_QUOTED, '') - if (baseDir.split(PATH_SEPARATOR_QUOTED).length > 1) { - beatsFolderName = baseDir.split(PATH_SEPARATOR_QUOTED)[1] - } - return beatsFolderName + return basedir.replace('x-pack/', '') } def withBeatsEnv(Closure body) { From 6a27a50ea3ffb566c71f532364e14a9cb2e49014 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Wed, 2 Sep 2020 13:11:37 +0100 Subject: [PATCH 4/4] Update .ci/packaging.groovy Co-authored-by: Ivan Fernandez Calvo --- .ci/packaging.groovy | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.ci/packaging.groovy b/.ci/packaging.groovy index 13c5d044bb4a..57a99a74f63e 100644 --- a/.ci/packaging.groovy +++ b/.ci/packaging.groovy @@ -247,6 +247,9 @@ def publishPackages(baseDir){ * There is a specific folder structure in https://staging.elastic.co/ and https://artifacts.elastic.co/downloads/ * therefore the storage bucket in GCP should follow the same folder structure. * This is required by https://github.com/elastic/beats-tester +* e.g. +* baseDir=name -> return name +* baseDir=name1/name2/name3-> return name2 */ def getBeatsName(baseDir) { return basedir.replace('x-pack/', '')