Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft #1499

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

Draft #1499

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion src/main/java/hudson/plugins/git/GitSCM.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.concurrent.TimeUnit;

import static hudson.init.InitMilestone.JOB_LOADED;
import static hudson.init.InitMilestone.PLUGINS_STARTED;
Expand Down Expand Up @@ -1302,7 +1303,27 @@ public void checkout(Run<?, ?> build, Launcher launcher, FilePath workspace, Tas
ext.beforeCheckout(this, build, git, listener);
}

retrieveChanges(build, git, listener);
boolean retrievedChanges = false;

for (int tryCount = 1; tryCount <= 5; tryCount++) {
try {
retrieveChanges(build, git, listener);
retrievedChanges = true;
break;
} catch (AbortException ex) {
int waitTime = tryCount * 10;
listener.getLogger().println("Failed to retrieve Git changes with an error. Will make another attempt after " + waitTime + " seconds.");
TimeUnit.SECONDS.sleep(waitTime);
}
}

if (!retrievedChanges)
{
String errorMessage = "Got a fatal error while retrieving Git changes. Reached maximum retry limit, won't try again.";
listener.getLogger().println(errorMessage);
throw new AbortException(errorMessage);
}

Build revToBuild = determineRevisionToBuild(build, buildData, environment, git, listener);

// Track whether we're trying to add a duplicate BuildData, now that it's been updated with
Expand Down
Loading