Skip to content

Commit e4ff918

Browse files
chore: upload files to Google Storage when they exist (#28836) (#28847)
* 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 20d637e) Co-authored-by: Manuel de la Peña <[email protected]>
1 parent a68567b commit e4ff918

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

Jenkinsfile

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -831,20 +831,23 @@ def archiveTestOutput(Map args = [:]) {
831831
catchError(buildResult: 'SUCCESS', message: 'Failed to archive the build test results', stageResult: 'SUCCESS') {
832832
withMageEnv(version: "${env.GO_VERSION}"){
833833
dir(directory){
834-
cmd(label: "Archive system tests files", script: 'mage packageSystemTests')
834+
cmd(label: "Archive system tests files", script: 'mage packageSystemTests', returnStatus: true)
835835
}
836836
}
837+
837838
def fileName = 'build/system-tests-*.tar.gz' // see dev-tools/mage/target/common/package.go#PackageSystemTests method
838839
def files = findFiles(glob: "${fileName}")
839-
files.each { file ->
840-
echo "${file.name}"
840+
841+
if (files?.length() > 0) {
842+
googleStorageUploadExt(
843+
bucket: "gs://${JOB_GCS_BUCKET}/${env.JOB_NAME}-${env.BUILD_ID}",
844+
credentialsId: "${JOB_GCS_EXT_CREDENTIALS}",
845+
pattern: "${fileName}",
846+
sharedPublicly: true
847+
)
848+
} else {
849+
log(level: 'WARN', text: "There are no system-tests files to upload Google Storage}")
841850
}
842-
googleStorageUploadExt(
843-
bucket: "gs://${JOB_GCS_BUCKET}/${env.JOB_NAME}-${env.BUILD_ID}",
844-
credentialsId: "${JOB_GCS_EXT_CREDENTIALS}",
845-
pattern: "${fileName}",
846-
sharedPublicly: true
847-
)
848851
}
849852
}
850853
}

0 commit comments

Comments
 (0)