diff --git a/Jenkinsfile b/Jenkinsfile index 5e663fd..55f85d4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -99,11 +99,20 @@ spec: echo "${HARBOR_VERSION}" exit 0 fi - curl -sSL https://api.github.com/repos/goharbor/harbor/releases/latest | python3 - <<'PY' -import json, sys -data = json.load(sys.stdin) -print(data.get("tag_name", "").strip()) -PY + for attempt in 1 2 3; do + version=$(curl -fsSL \ + -H 'Accept: application/vnd.github+json' \ + -H 'User-Agent: harbor-arm-build' \ + https://api.github.com/repos/goharbor/harbor/releases/latest \ + | jq -r '.tag_name // empty') || version="" + if [ -n "${version}" ]; then + echo "${version}" + exit 0 + fi + sleep $((attempt * 5)) + done + echo "Failed to resolve Harbor version from GitHub; set HARBOR_VERSION manually." >&2 + exit 1 ''' ).trim() env.HARBOR_VERSION_RESOLVED = resolved