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 {
|
post {
|
||||||
always {
|
always {
|
||||||
script {
|
script {
|
||||||
if (fileExists('build/junit-unit.xml') || fileExists('build/junit-glue.xml')) {
|
try {
|
||||||
try {
|
if (fileExists('build/junit-unit.xml') || fileExists('build/junit-glue.xml')) {
|
||||||
junit allowEmptyResults: true, testResults: 'build/junit-*.xml'
|
try {
|
||||||
} catch (Throwable err) {
|
junit allowEmptyResults: true, testResults: 'build/junit-*.xml'
|
||||||
echo "junit step unavailable: ${err.class.simpleName}"
|
} 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 {
|
script {
|
||||||
env.FLUX_BRANCH = sh(
|
env.FLUX_BRANCH = sh(
|
||||||
returnStdout: true,
|
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()
|
).trim()
|
||||||
if (!env.FLUX_BRANCH) {
|
if (!env.FLUX_BRANCH) {
|
||||||
error('Flux branch not found in gotk-sync.yaml')
|
error('Flux branch not found in gotk-sync.yaml')
|
||||||
@ -426,15 +426,23 @@ PY
|
|||||||
post {
|
post {
|
||||||
always {
|
always {
|
||||||
script {
|
script {
|
||||||
if (fileExists('build/junit-unit.xml') || fileExists('build/junit-glue.xml')) {
|
try {
|
||||||
try {
|
if (fileExists('build/junit-unit.xml') || fileExists('build/junit-glue.xml')) {
|
||||||
junit allowEmptyResults: true, testResults: 'build/junit-*.xml'
|
try {
|
||||||
} catch (Throwable err) {
|
junit allowEmptyResults: true, testResults: 'build/junit-*.xml'
|
||||||
echo "junit step unavailable: ${err.class.simpleName}"
|
} 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 {
|
script {
|
||||||
env.QUALITY_OUTCOME = currentBuild.currentResult == 'SUCCESS' ? 'ok' : 'failed'
|
env.QUALITY_OUTCOME = currentBuild.currentResult == 'SUCCESS' ? 'ok' : 'failed'
|
||||||
}
|
}
|
||||||
container('git') {
|
script {
|
||||||
sh '''
|
try {
|
||||||
|
container('git') {
|
||||||
|
sh '''
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
apk add --no-cache curl jq >/dev/null 2>&1 || true
|
apk add --no-cache curl jq >/dev/null 2>&1 || true
|
||||||
suite="${SUITE_NAME}"
|
suite="${SUITE_NAME}"
|
||||||
@ -551,14 +553,20 @@ METRICS
|
|||||||
cat build/pushgateway-response.txt >&2 || true
|
cat build/pushgateway-response.txt >&2 || true
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
'''
|
'''
|
||||||
}
|
}
|
||||||
script {
|
if (fileExists('build/junit-data-prepper.xml')) {
|
||||||
if (fileExists('build/junit-data-prepper.xml')) {
|
echo 'JUnit XML generated and archived under build/; Jenkins junit step is not installed on this controller.'
|
||||||
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