From a1898d8bc06d80ed5e92c3c7480830803dc5fa6a Mon Sep 17 00:00:00 2001 From: kohsuke Date: Sun, 4 Nov 2007 02:44:36 +0000 Subject: [PATCH] - added a debug method to enable SSH logging. - disabled SSH connection pooling, which seems to improve the SSH connection stability. I was unable to connect to my intranet server before, but with this change it works now. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@5679 71c3de6d-444a-0410-be80-ed276b4c234a --- core/pom.xml | 12 +++++++++ .../main/java/hudson/scm/SubversionSCM.java | 25 +++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/core/pom.xml b/core/pom.xml index 342ccde3bd..2c8ca1f79b 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -231,6 +231,18 @@ org.jvnet.hudson.svnkit svnkit 1.1.4-hudson-3 + + + + ch.ethz.ganymed + ganymed-ssh2 + + + + + org.jvnet.hudson + ganymed-ssh2 + build210-hudson-1 ${groupId} diff --git a/core/src/main/java/hudson/scm/SubversionSCM.java b/core/src/main/java/hudson/scm/SubversionSCM.java index 5dbff4baf3..72907297c0 100644 --- a/core/src/main/java/hudson/scm/SubversionSCM.java +++ b/core/src/main/java/hudson/scm/SubversionSCM.java @@ -1,5 +1,6 @@ package hudson.scm; +import ch.ethz.ssh2.SCPClient; import hudson.FilePath; import hudson.FilePath.FileCallable; import hudson.Launcher; @@ -76,6 +77,7 @@ import java.util.Random; import java.util.StringTokenizer; import java.util.logging.Level; import java.util.logging.Logger; +import java.util.logging.ConsoleHandler; import java.util.regex.Pattern; /** @@ -1209,6 +1211,11 @@ public class SubversionSCM extends SCM implements Serializable { // work around for http://www.nabble.com/Slow-SVN-Checkout-tf4486786.html if(System.getProperty("svnkit.symlinks")==null) System.setProperty("svnkit.symlinks","false"); + + // disable the connection pooling, which causes problems like + // http://www.nabble.com/SSH-connection-problems-p12028339.html + if(System.getProperty("svnkit.ssh2.persistent")==null) + System.setProperty("svnkit.ssh2.persistent","false"); } } @@ -1237,4 +1244,22 @@ public class SubversionSCM extends SCM implements Serializable { } private static final Logger LOGGER = Logger.getLogger(SubversionSCM.class.getName()); + + /** + * Enables trace logging of Ganymed SSH library. + *

+ * Intended to be invoked from Groovy console. + */ + public static void enableSshDebug(Level level) { + if(level==null) level= Level.FINEST; // default + + Logger ganymedLogger = Logger.getLogger(SCPClient.class.getPackage().getName()); + ganymedLogger.setLevel(level); + ganymedLogger.setUseParentHandlers(false); + ConsoleHandler handler = new ConsoleHandler(); + handler.setLevel(level); + ganymedLogger.addHandler(handler); + + ch.ethz.ssh2.log.Logger.logLevel = 100; + } }