Skip to content
This repository was archived by the owner on Sep 30, 2023. It is now read-only.

Commit 9dedb57

Browse files
committed
retry if clone failed
1 parent b8b20f8 commit 9dedb57

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

Common/GitRepository.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public void Clone(string url, string treeish = null)
4646
log.Info($"{"[" + ModuleName + "]",-30}Cloning treeish {treeish ?? "master"} into {RepoPath}");
4747
var treeishSuffix = "-b " + (treeish ?? "master");
4848
var cmd = $"git clone {url} {treeishSuffix} \"{RepoPath}\" 2>&1";
49-
var exitCode = runner.Run(cmd, TimeSpan.FromMinutes(60));
49+
var exitCode = runner.Run(cmd, TimeSpan.FromMinutes(60), RetryStrategy.IfTimeoutOrFailed);
5050
if (exitCode != 0)
5151
{
5252
throw new GitCloneException($"Failed to clone {url}:{treeish}. Error message:{runner.Output}");

Common/ShellRunner.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ private int RunThreeTimes(string commandWithArguments, string workingDirectory,
101101
if (HasTimeout)
102102
timeout = TimoutHelper.IncreaceTimeout(timeout);
103103
exitCode = RunOnce(commandWithArguments, workingDirectory, timeout);
104+
log.Debug($"EXECUTED {startInfo.FileName} {startInfo.Arguments} in {workingDirectory} with exitCode {exitCode} and retryStrategy {retryStrategy}");
104105
}
105106
return exitCode;
106107
}
@@ -207,9 +208,9 @@ public int Run(string commandWithArguments)
207208
return Run(commandWithArguments, DefaultTimeout);
208209
}
209210

210-
public int Run(string commandWithArguments, TimeSpan timeout)
211+
public int Run(string commandWithArguments, TimeSpan timeout, RetryStrategy retryStrategy = RetryStrategy.IfTimeout)
211212
{
212-
return RunThreeTimes(commandWithArguments, Directory.GetCurrentDirectory(), timeout);
213+
return RunThreeTimes(commandWithArguments, Directory.GetCurrentDirectory(), timeout, retryStrategy);
213214
}
214215

215216
public int RunInDirectory(string path, string commandWithArguments)

0 commit comments

Comments
 (0)