Jenkins: retry checkout scm with backoff and debug diagnostics on failure - #5186
Open
causten wants to merge 4 commits into
Open
Jenkins: retry checkout scm with backoff and debug diagnostics on failure#5186causten wants to merge 4 commits into
causten wants to merge 4 commits into
Conversation
…lure Replaces all bare `checkout scm` calls with a `checkoutWithRetry` helper that uses the Git plugin's CloneOption retryFetchCount, retries up to 3 times with exponential backoff (15s, 30s), and emits network/git diagnostics (remote config, routing, GitHub reachability) only on final failure so transient fetch errors don't require manual re-triggers. Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens Jenkins SCM checkout behavior by introducing a reusable retry wrapper around Git checkouts, aiming to reduce transient-network related pipeline failures and emit actionable diagnostics when checkout ultimately fails.
Changes:
- Added a
checkoutWithRetryhelper that performs Jenkins Git checkouts with plugin-level fetch retry plus Groovy-level retries and backoff. - Replaced the existing
checkout scmusages in the pipeline withcheckoutWithRetry()to apply consistent retry/diagnostic behavior.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| userRemoteConfigs: scm.userRemoteConfigs, | ||
| ]) | ||
| return | ||
| } catch (Exception e) { |
Comment on lines
+178
to
+181
| sh 'git remote -v || true' | ||
| sh 'git config --list || true' | ||
| sh 'ip route || true' | ||
| sh 'curl -sv https://github.com 2>&1 | tail -20 || true' |
Comment on lines
+184
to
+186
| def delay = 15 * attempt | ||
| echo "checkout scm failed (attempt ${attempt}/${maxAttempts}): ${e.message}. Retrying in ${delay}s..." | ||
| sleep(time: delay, unit: 'SECONDS') |
…hRetry Rethrow FlowInterruptedException and InterruptedException immediately so pipeline aborts and timeouts are not swallowed by the retry loop. Filter token/password/auth/header keys from git config --list output to avoid exposing the Authorization extraheader that the Git plugin writes into .git/config when using credential helpers. Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
Suppressed comments (1)
Jenkinsfile:187
delay = 15 * attemptis linear ifmaxAttemptsis increased, which doesn’t match the stated exponential-backoff intent for this helper. Use a true exponential formula so increasingmaxAttemptsdoesn’t accidentally reduce resiliency under persistent transient failures.
def delay = 15 * attempt
Comment on lines
+181
to
+184
| sh 'git remote -v || true' | ||
| sh 'git config --list | grep -v -i "token\\|password\\|auth\\|header" || true' | ||
| sh 'ip route || true' | ||
| sh 'curl -sv https://github.com 2>&1 | tail -20 || true' |
…nostic git remote -v and remote.*.url in git config can expose embedded HTTPS credentials. Drop remote -v entirely (curl already probes GitHub reachability) and extend the grep filter to exclude .url keys from git config --list output. Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>
Regressions detected 🔴 * No develop baseline was found for this PR's branch point; compared against the latest available develop run instead. |
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
checkoutWithRetryhelper that replaces all 5 barecheckout scmcalls in the JenkinsfileCloneOption(retryFetchCount: 3)for plugin-level fetch retries before Groovy sees the errorgit remote -v,git config --list,ip route, and a curl probe to github.comMotivation
PR-5185 build #1 failed with a
git fetcherror. The failure was transient (network blip during SCM checkout) but caused a full pipeline failure requiring a manual re-trigger. This change makes all checkout points self-healing for transient errors and captures actionable diagnostics when they aren't.Test plan
setupstage completes successfully🤖 Generated with Claude Code