ci: harden unit test step and junit post

This commit is contained in:
Brad Stein 2026-01-21 03:47:08 -03:00
parent 8930161926
commit a228e063f1

12
Jenkinsfile vendored
View File

@ -95,7 +95,7 @@ spec:
stage('Unit tests') { stage('Unit tests') {
steps { steps {
container('tester') { container('tester') {
sh ''' sh(script: '''
set -euo pipefail set -euo pipefail
python -m pip install --no-cache-dir -r requirements.txt -r requirements-dev.txt python -m pip install --no-cache-dir -r requirements.txt -r requirements-dev.txt
mkdir -p build mkdir -p build
@ -114,7 +114,7 @@ spec:
percent = summary.get("percent_covered") percent = summary.get("percent_covered")
print(f"Coverage summary: {percent:.2f}%" if percent is not None else "Coverage summary unavailable") print(f"Coverage summary: {percent:.2f}%" if percent is not None else "Coverage summary unavailable")
PY PY
''' '''.stripIndent())
} }
} }
} }
@ -204,7 +204,15 @@ spec:
post { post {
always { always {
script {
if (fileExists('build/junit.xml')) {
try {
junit allowEmptyResults: true, testResults: 'build/junit.xml' junit allowEmptyResults: true, testResults: 'build/junit.xml'
} catch (Throwable err) {
echo "junit step unavailable: ${err.class.simpleName}"
}
}
}
archiveArtifacts artifacts: 'build/junit.xml,build/coverage.json', allowEmptyArchive: true, fingerprint: true archiveArtifacts artifacts: 'build/junit.xml,build/coverage.json', allowEmptyArchive: true, fingerprint: true
script { script {
def props = fileExists('build.env') ? readProperties(file: 'build.env') : [:] def props = fileExists('build.env') ? readProperties(file: 'build.env') : [:]