From 0f0d666cd60737e8025aacc853d7329e0688e5b1 Mon Sep 17 00:00:00 2001 From: Matanelc Date: Wed, 23 Aug 2023 10:39:12 +0300 Subject: [PATCH 1/2] Update GitSCM.java --- src/main/java/hudson/plugins/git/GitSCM.java | 22 +++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/main/java/hudson/plugins/git/GitSCM.java b/src/main/java/hudson/plugins/git/GitSCM.java index a26f51363b..5fcaa45762 100644 --- a/src/main/java/hudson/plugins/git/GitSCM.java +++ b/src/main/java/hudson/plugins/git/GitSCM.java @@ -1302,7 +1302,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 From 155c9a273b13ee8909b3938dc9e18fa1304f6c6b Mon Sep 17 00:00:00 2001 From: Matanelc Date: Wed, 23 Aug 2023 10:47:03 +0300 Subject: [PATCH 2/2] Update GitSCM.java --- src/main/java/hudson/plugins/git/GitSCM.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/hudson/plugins/git/GitSCM.java b/src/main/java/hudson/plugins/git/GitSCM.java index 5fcaa45762..c1c3387ffe 100644 --- a/src/main/java/hudson/plugins/git/GitSCM.java +++ b/src/main/java/hudson/plugins/git/GitSCM.java @@ -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;