From e4ff918ebc3843ca67a614bb6a24680f609a0ab0 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 5 Nov 2021 15:26:45 +0100 Subject: [PATCH] chore: upload files to Google Storage when they exist (#28836) (#28847) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: send to Google Storage when there are files * fix: prevent failures if mage exits with 1 * fix: define variable properly (cherry picked from commit 20d637e1afc7104e7a1f24532cd491e59ad6b245) Co-authored-by: Manuel de la Peña --- Jenkinsfile | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index d64020de9401..f783ebce3d52 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -831,20 +831,23 @@ def archiveTestOutput(Map args = [:]) { catchError(buildResult: 'SUCCESS', message: 'Failed to archive the build test results', stageResult: 'SUCCESS') { withMageEnv(version: "${env.GO_VERSION}"){ dir(directory){ - cmd(label: "Archive system tests files", script: 'mage packageSystemTests') + cmd(label: "Archive system tests files", script: 'mage packageSystemTests', returnStatus: true) } } + def fileName = 'build/system-tests-*.tar.gz' // see dev-tools/mage/target/common/package.go#PackageSystemTests method def files = findFiles(glob: "${fileName}") - files.each { file -> - echo "${file.name}" + + if (files?.length() > 0) { + googleStorageUploadExt( + bucket: "gs://${JOB_GCS_BUCKET}/${env.JOB_NAME}-${env.BUILD_ID}", + credentialsId: "${JOB_GCS_EXT_CREDENTIALS}", + pattern: "${fileName}", + sharedPublicly: true + ) + } else { + log(level: 'WARN', text: "There are no system-tests files to upload Google Storage}") } - googleStorageUploadExt( - bucket: "gs://${JOB_GCS_BUCKET}/${env.JOB_NAME}-${env.BUILD_ID}", - credentialsId: "${JOB_GCS_EXT_CREDENTIALS}", - pattern: "${fileName}", - sharedPublicly: true - ) } } }