diff --git a/services/jenkins/configmap-jcasc.yaml b/services/jenkins/configmap-jcasc.yaml index 3c5822113..f84d2d797 100644 --- a/services/jenkins/configmap-jcasc.yaml +++ b/services/jenkins/configmap-jcasc.yaml @@ -605,11 +605,18 @@ data: writeFile file: 'test-runner-job.yaml', text: manifest.join('\\n') + '\\n' sh 'kubectl -n hermes-triage-demo create -f test-runner-job.yaml' def verdict = 'unknown' + // Read the container's exit code, not the Job status. + // The kubelet records the exit code the moment the + // container stops; the Job controller can take minutes + // to reconcile .status.failed, and has been observed + // taking over half an hour on this cluster. Waiting on + // the Job made the build look hung long after the test + // had actually finished. timeout(time: 3, unit: 'MINUTES') { waitUntil { - def st = sh(script: 'kubectl -n hermes-triage-demo get job ' + jobName + ' -o jsonpath={.status.succeeded}:{.status.failed}', returnStdout: true).trim() - if (st.startsWith('1')) { verdict = 'pass'; return true } - if (st.endsWith(':1')) { verdict = 'fail'; return true } + def code = sh(script: 'kubectl -n hermes-triage-demo get pods -l job-name=' + jobName + ' -o jsonpath="{.items[0].status.containerStatuses[0].state.terminated.exitCode}" 2>/dev/null || true', returnStdout: true).trim() + if (code == '0') { verdict = 'pass'; return true } + if (code != '') { verdict = 'fail'; return true } return false } }