Skip to content
Permalink
Browse files

[JENKINS-11286] run git commands with a time-out

  • Loading branch information
ndeloof committed Oct 28, 2013
1 parent ddfde14 commit 1b7fd2b18d626d8ca081933d8a004fd7b2279210
Showing with 10 additions and 1 deletion.
  1. +10 −1 src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java
@@ -51,6 +51,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

@@ -973,7 +974,7 @@ private String launchCommandIn(ArgumentListBuilder args, File workDir, String pu
Launcher.ProcStarter p = launcher.launch().cmds(args.toCommandArray()).
envs(environment).stdout(fos).stderr(err);
if (workDir != null) p.pwd(workDir);
int status = p.join();
int status = p.start().joinWithTimeout(TIMEOUT, TimeUnit.MINUTES, listener);

String result = fos.toString();
if (status != 0) {
@@ -1483,4 +1484,12 @@ public GetPrivateKeys(SSHUserPrivateKey sshUser) {
return sshUser.getPrivateKeys();
}
}

/**
* preventive Time-out for git command execution.
* <p>
* We run git as an external process so can't guarantee it won't hang for whatever reason. Even plugin does its
* best to avoid git interactively asking for credentials, but there's a bunch of other cases git may hung.
*/
public static int TIMEOUT = Integer.getInteger(Git.class.getName() + ".timeOut", 10);
}

0 comments on commit 1b7fd2b

Please sign in to comment.
You can’t perform that action at this time.