Skip to content
Permalink
Browse files

JENKINS-25600 fix user abort

  • Loading branch information
JeremyMarshall committed Nov 16, 2014
1 parent d29b3cb commit 2ffbffa3dc993d188a39df7db6cbb93cdd43aaa9
Showing with 26 additions and 20 deletions.
  1. +26 −20 src/main/java/hudson/plugins/xshell/XShellBuilder.java
@@ -137,26 +137,32 @@ public boolean perform(final AbstractBuild<?, ?> build, final Launcher launcher,

Long startTime = System.currentTimeMillis();

while(child.isAlive()){

baos.flush();
String s = baos.toString();
baos.reset();

listener.getLogger().print(s);
listener.getLogger().flush();

if ((this.regexToKill != null) && (this.regexToKill.length() > 0) && (r.matcher(s).find())){
LOG.log(Level.FINEST, "Matched failure in log");
child.kill();
listener.getLogger().println("Matched <" + this.regexToKill +"> in output. Terminated");
}else if( (timeAllowed > 0) && ((System.currentTimeMillis() - startTime) / 1000) > timeAllowed){
LOG.log(Level.FINEST, "Timed out");
child.kill();
listener.getLogger().println("Timed out <" + this.timeAllocated +">. Terminated");
}else{
Thread.sleep(2);
}
try {
while (child.isAlive()) {

baos.flush();
String s = baos.toString();
baos.reset();

listener.getLogger().print(s);
listener.getLogger().flush();

if ((this.regexToKill != null) && (this.regexToKill.length() > 0) && (r.matcher(s).find())) {
LOG.log(Level.FINEST, "Matched failure in log");
child.kill();
listener.getLogger().println("Matched <" + this.regexToKill + "> in output. Terminated");
} else if ((timeAllowed > 0) && ((System.currentTimeMillis() - startTime) / 1000) > timeAllowed) {
LOG.log(Level.FINEST, "Timed out");
child.kill();
listener.getLogger().println("Timed out <" + this.timeAllocated + ">. Terminated");
} else {
Thread.sleep(2);
}
}
} catch (InterruptedException intEx) {
LOG.log(Level.FINEST, "Aborted by user");
child.kill();
listener.getLogger().println("Aborted by User. Terminated");
}

baos.flush();

0 comments on commit 2ffbffa

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