Skip to content
Permalink
Browse files

Merge pull request #13 from JeremyMarshall/master

JENKINS-25600 fix user abort
  • Loading branch information
mambu committed Dec 29, 2014
2 parents d29b3cb + 644621b commit 9da2ce427c43f4db9fa062cf4a1e8e6943a0810b
Showing with 27 additions and 20 deletions.
  1. +27 −20 src/main/java/hudson/plugins/xshell/XShellBuilder.java
@@ -137,26 +137,33 @@ 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");
throw(new InterruptedException("User Aborted"));
}

baos.flush();

0 comments on commit 9da2ce4

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