ci(jenkins): retry transient go fetch/test failures

This commit is contained in:
Brad Stein 2026-04-18 17:29:50 -03:00
parent 6f9dfaa714
commit 265be3eeab

39
Jenkinsfile vendored
View File

@ -119,11 +119,36 @@ spec:
apt-get update >/dev/null
apt-get install -y --no-install-recommends xz-utils >/dev/null
mkdir -p build
export GOPROXY='https://proxy.golang.org,direct'
export GOSUMDB='sum.golang.org'
for attempt in 1 2 3; do
if go mod download >/dev/null 2>&1; then
break
fi
if [ "${attempt}" -eq 3 ]; then
echo "go mod download failed after ${attempt} attempts" >&2
break
fi
sleep $((attempt * 3))
done
go install github.com/jstemmer/go-junit-report/v2@latest
set +e
go test -v -coverprofile=build/coverage.out ./... > build/test.out 2>&1
test_rc=$?
set -e
test_rc=1
for attempt in 1 2 3; do
set +e
go test -v -count=1 -coverprofile=build/coverage.out ./... > build/test.out 2>&1
test_rc=$?
set -e
if [ "${test_rc}" -eq 0 ]; then
break
fi
if ! grep -q 'TLS handshake timeout' build/test.out 2>/dev/null; then
break
fi
if [ "${attempt}" -eq 3 ]; then
break
fi
sleep $((attempt * 3))
done
printf '%s\n' "${test_rc}" > "${TEST_EXIT_CODE_PATH}"
cat build/test.out
"$(go env GOPATH)/bin/go-junit-report" < build/test.out > "${JUNIT_XML}"
@ -140,10 +165,12 @@ spec:
stage('Publish test metrics') {
steps {
container('publisher') {
container('tester') {
sh '''
set -eu
python scripts/publish_test_metrics.py
apt-get update >/dev/null
apt-get install -y --no-install-recommends python3 >/dev/null
python3 scripts/publish_test_metrics.py
'''
}
}