From a2f5cdcf816ee83c48932f3dc411950c9450efd7 Mon Sep 17 00:00:00 2001 From: Damien Duportal Date: Wed, 6 Nov 2024 18:43:34 +0100 Subject: [PATCH 1/5] chore(Jenkinsfile) collect `azcopy` publication logs when failing deployment on trusted.ci.jenkins.io Inspired by https://github.com/jenkins-infra/javadoc/blob/238c39e60a4e2adfb179539ad03f67d24eb39008/Jenkinsfile#L52-L87 --- Jenkinsfile | 48 +++++++++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index c2f11171d074..c368e9084f83 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -86,29 +86,39 @@ node('docker&&linux') { */ if (infra.isTrusted() && env.BRANCH_NAME == null) { stage('Publish site') { - infra.withFileShareServicePrincipal([ - servicePrincipalCredentialsId: 'trustedci_jenkinsio_fileshare_serviceprincipal_writer', - fileShare: 'jenkins-io', - fileShareStorageAccount: 'jenkinsio' - ]) { + try { + infra.withFileShareServicePrincipal([ + servicePrincipalCredentialsId: 'trustedci_jenkinsio_fileshare_serviceprincipal_writer', + fileShare: 'jenkins-io', + fileShareStorageAccount: 'jenkinsio' + ]) { + sh ''' + # Don't output sensitive information + set +x + + # Synchronize the File Share content + azcopy sync \ + --skip-version-check \ + --recursive=true\ + --delete-destination=true \ + --compare-hash=MD5 \ + --put-md5 \ + --local-hash-storage-mode=HiddenFiles \ + ./build/_site/ "${FILESHARE_SIGNED_URL}" + + # Retrieve azcopy logs to archive them + cat /home/jenkins/.azcopy/*.log > azcopy.log + ''' + archiveArtifacts 'azcopy.log' + } + } catch (err) { + currentBuild.result = 'FAILURE' + // Only collect azcopy log when the deployment fails, because it is an heavy one sh ''' - # Don't output sensitive information - set +x - - # Synchronize the File Share content - azcopy sync \ - --skip-version-check \ - --recursive=true\ - --delete-destination=true \ - --compare-hash=MD5 \ - --put-md5 \ - --local-hash-storage-mode=HiddenFiles \ - ./build/_site/ "${FILESHARE_SIGNED_URL}" - # Retrieve azcopy logs to archive them cat /home/jenkins/.azcopy/*.log > azcopy.log ''' - archiveArtifacts 'azcopy.log' + archiveArtifacts 'azcopy.log' } } stage('Purge cached CSS') { From 5a552637eb521fa8ef09ecd6f1094627159fc62c Mon Sep 17 00:00:00 2001 From: Damien Duportal Date: Thu, 7 Nov 2024 18:47:24 +0100 Subject: [PATCH 2/5] Apply suggestions from code review Co-authored-by: lemeurherveCB <137290663+lemeurherveCB@users.noreply.github.com> --- Jenkinsfile | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index c368e9084f83..a7b425b837fb 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -105,11 +105,6 @@ node('docker&&linux') { --put-md5 \ --local-hash-storage-mode=HiddenFiles \ ./build/_site/ "${FILESHARE_SIGNED_URL}" - - # Retrieve azcopy logs to archive them - cat /home/jenkins/.azcopy/*.log > azcopy.log - ''' - archiveArtifacts 'azcopy.log' } } catch (err) { currentBuild.result = 'FAILURE' @@ -118,7 +113,7 @@ node('docker&&linux') { # Retrieve azcopy logs to archive them cat /home/jenkins/.azcopy/*.log > azcopy.log ''' - archiveArtifacts 'azcopy.log' + archiveArtifacts 'azcopy.log' } } stage('Purge cached CSS') { From 67b4daf79d460759f3901cb7b20746bb6b50e84f Mon Sep 17 00:00:00 2001 From: Damien Duportal Date: Thu, 7 Nov 2024 18:48:33 +0100 Subject: [PATCH 3/5] Update Jenkinsfile --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index a7b425b837fb..28b589e3650d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -105,6 +105,7 @@ node('docker&&linux') { --put-md5 \ --local-hash-storage-mode=HiddenFiles \ ./build/_site/ "${FILESHARE_SIGNED_URL}" + ''' } } catch (err) { currentBuild.result = 'FAILURE' From dca243337c816c059cf7a7bd86991f1de30ae2f7 Mon Sep 17 00:00:00 2001 From: Damien Duportal Date: Thu, 7 Nov 2024 18:49:01 +0100 Subject: [PATCH 4/5] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 28b589e3650d..cf77bb03ef8d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -105,7 +105,7 @@ node('docker&&linux') { --put-md5 \ --local-hash-storage-mode=HiddenFiles \ ./build/_site/ "${FILESHARE_SIGNED_URL}" - ''' + ''' } } catch (err) { currentBuild.result = 'FAILURE' From eb13ad3504664f79f143c62779ae711c2d1fb67a Mon Sep 17 00:00:00 2001 From: Damien Duportal Date: Thu, 7 Nov 2024 18:49:20 +0100 Subject: [PATCH 5/5] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index cf77bb03ef8d..8833e28e61c3 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -105,7 +105,7 @@ node('docker&&linux') { --put-md5 \ --local-hash-storage-mode=HiddenFiles \ ./build/_site/ "${FILESHARE_SIGNED_URL}" - ''' + ''' } } catch (err) { currentBuild.result = 'FAILURE'