ci(jenkins): tolerate missing workspace in post actions
This commit is contained in:
parent
e3e8a046e4
commit
ba84082a1e
20
Jenkinsfile
vendored
20
Jenkinsfile
vendored
@ -427,15 +427,23 @@ PY
|
||||
post {
|
||||
always {
|
||||
script {
|
||||
if (fileExists('build/junit-unit.xml') || fileExists('build/junit-glue.xml')) {
|
||||
try {
|
||||
junit allowEmptyResults: true, testResults: 'build/junit-*.xml'
|
||||
} catch (Throwable err) {
|
||||
echo "junit step unavailable: ${err.class.simpleName}"
|
||||
try {
|
||||
if (fileExists('build/junit-unit.xml') || fileExists('build/junit-glue.xml')) {
|
||||
try {
|
||||
junit allowEmptyResults: true, testResults: 'build/junit-*.xml'
|
||||
} catch (Throwable err) {
|
||||
echo "junit step unavailable: ${err.class.simpleName}"
|
||||
}
|
||||
}
|
||||
archiveArtifacts artifacts: 'build/**', allowEmptyArchive: true, fingerprint: true
|
||||
} catch (Throwable err) {
|
||||
if (err.class.simpleName == 'MissingContextVariableException') {
|
||||
echo 'workspace unavailable; skipping post-build artifact collection'
|
||||
} else {
|
||||
throw err
|
||||
}
|
||||
}
|
||||
}
|
||||
archiveArtifacts artifacts: 'build/**', allowEmptyArchive: true, fingerprint: true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -380,7 +380,7 @@ PY
|
||||
script {
|
||||
env.FLUX_BRANCH = sh(
|
||||
returnStdout: true,
|
||||
script: "awk '/branch:/{print $2; exit}' clusters/atlas/flux-system/gotk-sync.yaml"
|
||||
script: "grep -m1 '^\\s*branch:' clusters/atlas/flux-system/gotk-sync.yaml | sed 's/^\\s*branch:\\s*//'"
|
||||
).trim()
|
||||
if (!env.FLUX_BRANCH) {
|
||||
error('Flux branch not found in gotk-sync.yaml')
|
||||
@ -426,15 +426,23 @@ PY
|
||||
post {
|
||||
always {
|
||||
script {
|
||||
if (fileExists('build/junit-unit.xml') || fileExists('build/junit-glue.xml')) {
|
||||
try {
|
||||
junit allowEmptyResults: true, testResults: 'build/junit-*.xml'
|
||||
} catch (Throwable err) {
|
||||
echo "junit step unavailable: ${err.class.simpleName}"
|
||||
try {
|
||||
if (fileExists('build/junit-unit.xml') || fileExists('build/junit-glue.xml')) {
|
||||
try {
|
||||
junit allowEmptyResults: true, testResults: 'build/junit-*.xml'
|
||||
} catch (Throwable err) {
|
||||
echo "junit step unavailable: ${err.class.simpleName}"
|
||||
}
|
||||
}
|
||||
archiveArtifacts artifacts: 'build/**', allowEmptyArchive: true, fingerprint: true
|
||||
} catch (Throwable err) {
|
||||
if (err.class.simpleName == 'MissingContextVariableException') {
|
||||
echo 'workspace unavailable; skipping post-build artifact collection'
|
||||
} else {
|
||||
throw err
|
||||
}
|
||||
}
|
||||
}
|
||||
archiveArtifacts artifacts: 'build/**', allowEmptyArchive: true, fingerprint: true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -412,8 +412,10 @@ EOF
|
||||
script {
|
||||
env.QUALITY_OUTCOME = currentBuild.currentResult == 'SUCCESS' ? 'ok' : 'failed'
|
||||
}
|
||||
container('git') {
|
||||
sh '''
|
||||
script {
|
||||
try {
|
||||
container('git') {
|
||||
sh '''
|
||||
set -euo pipefail
|
||||
apk add --no-cache curl jq >/dev/null 2>&1 || true
|
||||
suite="${SUITE_NAME}"
|
||||
@ -551,14 +553,20 @@ METRICS
|
||||
cat build/pushgateway-response.txt >&2 || true
|
||||
;;
|
||||
esac
|
||||
'''
|
||||
}
|
||||
script {
|
||||
if (fileExists('build/junit-data-prepper.xml')) {
|
||||
echo 'JUnit XML generated and archived under build/; Jenkins junit step is not installed on this controller.'
|
||||
'''
|
||||
}
|
||||
if (fileExists('build/junit-data-prepper.xml')) {
|
||||
echo 'JUnit XML generated and archived under build/; Jenkins junit step is not installed on this controller.'
|
||||
}
|
||||
archiveArtifacts artifacts: 'build/**', allowEmptyArchive: true, fingerprint: true
|
||||
} catch (Throwable err) {
|
||||
if (err.class.simpleName == 'MissingContextVariableException') {
|
||||
echo 'workspace unavailable; skipping post-build metrics and artifact collection'
|
||||
} else {
|
||||
throw err
|
||||
}
|
||||
}
|
||||
}
|
||||
archiveArtifacts artifacts: 'build/**', allowEmptyArchive: true, fingerprint: true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user