From 18c570448b2e0c89493c4b42044ceb6e3a699200 Mon Sep 17 00:00:00 2001 From: codex Date: Tue, 21 Apr 2026 10:51:55 -0300 Subject: [PATCH] ci(metis): retry transient go module fetches --- Jenkinsfile | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 792d1a7..ad56dab 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -190,6 +190,26 @@ PY apt-get install -y --no-install-recommends xz-utils >/dev/null mkdir -p build go install github.com/jstemmer/go-junit-report/v2@latest + export GOPROXY="${GOPROXY:-https://proxy.golang.org,direct}" + retry_command() { + attempts=4 + delay=8 + attempt=1 + while [ "${attempt}" -le "${attempts}" ]; do + "$@" + rc=$? + if [ "${rc}" -eq 0 ]; then + return 0 + fi + if [ "${attempt}" -eq "${attempts}" ]; then + return "${rc}" + fi + echo "command failed with rc=${rc}; retrying in ${delay}s (${attempt}/${attempts})" + sleep "${delay}" + delay=$((delay * 2)) + attempt=$((attempt + 1)) + done + } cd "${WORKSPACE}" docs_rc=1 quality_rc=1 @@ -197,17 +217,17 @@ PY set +e cd "${WORKSPACE}/testing" - METIS_USE_EXISTING_COVERAGE=1 go test -v -run TestExportedDocs ./... + retry_command env METIS_USE_EXISTING_COVERAGE=1 go test -v -run TestExportedDocs ./... docs_rc=$? printf '%s\n' "${docs_rc}" > "${WORKSPACE}/build/docs-naming.rc" if [ "${docs_rc}" -eq 0 ]; then - METIS_USE_EXISTING_COVERAGE=1 go test -v ./... + retry_command env METIS_USE_EXISTING_COVERAGE=1 go test -v ./... quality_rc=$? fi cd "${WORKSPACE}" if [ "${docs_rc}" -eq 0 ] && [ "${quality_rc}" -eq 0 ]; then - go test -v -count=1 -coverprofile=build/coverage.out ./... > build/test.out 2>&1 + retry_command go test -v -count=1 -coverprofile=build/coverage.out ./... > build/test.out 2>&1 test_rc=$? fi set -e