feature(ci): set build description even if it fails

QA needs easier access to public URLs from DigitalOcean spaces, and when
this meta-job fails the URLs are buried within child jobs and hard to access.

This not only sets the description if build fails, it sets it after
every single child build finishes.

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2023-10-31 20:03:43 +01:00
parent 59048b2069
commit 9e8796f161
No known key found for this signature in database
GPG Key ID: FE65CD384D5BF7B4
1 changed files with 36 additions and 37 deletions

View File

@ -1,6 +1,9 @@
#!/usr/bin/env groovy #!/usr/bin/env groovy
library 'status-jenkins-lib@v1.8.0' library 'status-jenkins-lib@v1.8.0'
/* Object to store public URLs for description. */
urls = [:]
pipeline { pipeline {
agent { label 'linux' } agent { label 'linux' }
@ -29,16 +32,24 @@ pipeline {
stage('Build') { stage('Build') {
parallel { parallel {
stage('Linux/x86_64') { steps { script { stage('Linux/x86_64') { steps { script {
linux_x86_64 = jenkins.Build('status-desktop/systems/linux/x86_64/package') linux_x86_64 = getArtifacts(
'Linux', jenkins.Build('status-desktop/systems/linux/x86_64/package')
)
} } } } } }
stage('Windows/x86_64') { steps { script { stage('Windows/x86_64') { steps { script {
windows_x86_64 = jenkins.Build('status-desktop/systems/windows/x86_64/package') windows_x86_64 = getArtifacts(
'Windows', jenkins.Build('status-desktop/systems/windows/x86_64/package')
)
} } } } } }
stage('MacOS/x86_64') { steps { script { stage('MacOS/x86_64') { steps { script {
macos_x86_64 = jenkins.Build('status-desktop/systems/macos/x86_64/package') macos_x86_64 = getArtifacts(
'MacOS/x86_64', jenkins.Build('status-desktop/systems/macos/x86_64/package')
)
} } } } } }
stage('MacOS/aarch64') { steps { script { stage('MacOS/aarch64') { steps { script {
macos_aarch64 = jenkins.Build('status-desktop/systems/macos/aarch64/package') macos_aarch64 = getArtifacts(
'MacOS/aarch64', jenkins.Build('status-desktop/systems/macos/aarch64/package')
)
} } } } } }
} }
} }
@ -55,37 +66,6 @@ pipeline {
} } } } } }
} }
} }
stage('Archive') {
steps { script {
sh('rm -f pkg/*')
jenkins.copyArts(linux_x86_64)
jenkins.copyArts(windows_x86_64)
jenkins.copyArts(macos_x86_64)
jenkins.copyArts(macos_aarch64)
sha = "pkg/${utils.pkgFilename(ext: 'sha256')}"
dir('pkg') {
/* generate sha256 checksums for upload */
sh "sha256sum * | tee ../${sha}"
archiveArtifacts('*')
}
} }
}
stage('Upload') {
steps { script {
/* object for easier URLs handling */
urls = [
/* mobile */
'Linux': utils.pkgUrl(linux_x86_64),
'Windows': utils.pkgUrl(windows_x86_64),
'MacOS/x86_64': utils.pkgUrl(macos_x86_64),
'MacOS/aarch64': utils.pkgUrl(macos_aarch64),
/* upload the sha256 checksums file too */
SHA: s3.uploadArtifact(sha),
]
/* add URLs to the build description */
jenkins.setBuildDesc(urls)
} }
}
stage('Publish') { stage('Publish') {
when { expression { params.PUBLISH } } when { expression { params.PUBLISH } }
steps { script { steps { script {
@ -94,6 +74,14 @@ pipeline {
} }
} }
post { post {
always { script { dir('pkg') {
/* Generate sha256 checksums for all artifacts. */
sha = "./${utils.pkgFilename(ext: 'sha256')}"
sh "sha256sum * | tee ../${sha}"
archiveArtifacts('*')
urls['SHA'] = s3.uploadArtifact(sha)
jenkins.setBuildDesc(urls)
} } }
failure { script { failure { script {
withCredentials([ withCredentials([
string( string(
@ -114,6 +102,7 @@ pipeline {
) )
} }
} } } }
cleanup { cleanWs() }
} }
} }
@ -126,3 +115,13 @@ def Boolean getPublishDefault(Boolean previousValue) {
if (previousValue != null) { return previousValue } if (previousValue != null) { return previousValue }
return false return false
} }
/* Helper for getting artifacts from child builds. */
def getArtifacts(key, childBuild) {
/* Copy artifacts from child build to parent. */
jenkins.copyArts(childBuild)
/* Add new URL from child build and update description. */
urls[key] = utils.pkgUrl(childBuild)
jenkins.setBuildDesc(urls)
return childBuild
}