From 2121db7613035cc2f466a9c14aa5a7f2a4161db6 Mon Sep 17 00:00:00 2001 From: codex Date: Wed, 20 May 2026 04:25:51 -0300 Subject: [PATCH] ci(metis): harden transient agent failures --- Jenkinsfile | 58 +++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 43 insertions(+), 15 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3a91cac..469ca96 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,6 +2,7 @@ pipeline { agent { kubernetes { defaultContainer 'builder' + retries 2 yaml """ apiVersion: v1 kind: Pod @@ -29,6 +30,7 @@ spec: operator: NotIn values: - titan-13 + - titan-12 - titan-15 - titan-17 - titan-19 @@ -461,29 +463,55 @@ PY post { always { script { - if (fileExists(env.COVERAGE_JSON) && fileExists(env.JUNIT_XML)) { - withEnv(["QUALITY_GATE_FINAL_STATUS=${currentBuild.currentResult ?: 'SUCCESS'}"]) { - container('publisher') { - sh ''' - set -eu - python scripts/publish_test_metrics.py - ''' + try { + if (fileExists(env.COVERAGE_JSON) && fileExists(env.JUNIT_XML)) { + withEnv(["QUALITY_GATE_FINAL_STATUS=${currentBuild.currentResult ?: 'SUCCESS'}"]) { + container('publisher') { + sh ''' + set -eu + python scripts/publish_test_metrics.py + ''' + } } + } else { + echo 'quality metrics artifacts missing; skipping metrics publish' + } + } catch (Throwable err) { + if (err.class.simpleName == 'MissingContextVariableException') { + echo 'workspace unavailable; skipping metrics publish' + } else { + throw err } - } else { - echo 'quality metrics artifacts missing; skipping metrics publish' } } script { - if (fileExists('build/junit.xml')) { - try { - junit allowEmptyResults: true, testResults: 'build/junit.xml' - } catch (Throwable err) { - echo "junit step unavailable: ${err.class.simpleName}" + try { + if (fileExists('build/junit.xml')) { + try { + junit allowEmptyResults: true, testResults: 'build/junit.xml' + } catch (Throwable err) { + echo "junit step unavailable: ${err.class.simpleName}" + } + } + } catch (Throwable err) { + if (err.class.simpleName == 'MissingContextVariableException') { + echo 'workspace unavailable; skipping junit publish' + } else { + throw err + } + } + } + script { + try { + archiveArtifacts artifacts: 'build/**', allowEmptyArchive: true, fingerprint: true + } catch (Throwable err) { + if (err.class.simpleName == 'MissingContextVariableException') { + echo 'workspace unavailable; skipping artifact archive' + } else { + throw err } } } - archiveArtifacts artifacts: 'build/**', allowEmptyArchive: true, fingerprint: true } } }