Permalink
Browse files

[FIXED JENKINS-43518] Missing doStop method preventing abort from con…

…sole log
  • Loading branch information...
stephenc committed Jul 27, 2017
1 parent 077ed0f commit 05fadd7d7e26218dd73661fa89b44dfd60e311ed
Showing with 33 additions and 0 deletions.
  1. +33 −0 src/main/java/com/cloudbees/hudson/plugins/folder/computed/FolderComputation.java
@@ -38,18 +38,22 @@
import hudson.model.BallColor;
import hudson.model.Cause;
import hudson.model.CauseAction;
import hudson.model.Computer;
import hudson.model.Executor;
import hudson.model.Items;
import hudson.model.Queue;
import hudson.model.Result;
import hudson.model.Run;
import hudson.model.Saveable;
import hudson.model.StreamBuildListener;
import hudson.model.TaskListener;
import hudson.model.TopLevelItem;
import hudson.model.listeners.SaveableListener;
import hudson.model.queue.Executables;
import hudson.model.queue.QueueTaskDispatcher;
import hudson.util.AlternativeUiTextProvider;
import hudson.util.AlternativeUiTextProvider.Message;
import hudson.util.HttpResponses;
import hudson.util.StreamTaskListener;
import hudson.util.io.ReopenableRotatingFileOutputStream;
import java.io.ByteArrayInputStream;
@@ -70,14 +74,19 @@
import java.util.logging.Logger;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import javax.servlet.ServletException;
import jenkins.model.Jenkins;
import net.jcip.annotations.GuardedBy;
import org.apache.commons.io.Charsets;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.jelly.XMLOutput;
import org.kohsuke.stapler.HttpResponse;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
import org.kohsuke.stapler.export.Exported;
import org.kohsuke.stapler.framework.io.ByteBuffer;
import org.kohsuke.stapler.interceptor.RequirePOST;
/**
* A particular “run” of {@link ComputedFolder}.
@@ -373,6 +382,30 @@ public void doConsoleText(StaplerRequest req, StaplerResponse rsp) throws IOExce
}
}
/**
* Stops this build if it's still going.
*
* @return the Http response.
*/
@RequirePOST
public synchronized HttpResponse doStop() throws IOException, ServletException {
Executor e = Executor.of(this);
if (e == null) {
for (Computer c : Jenkins.getActiveInstance().getComputers()) {
for (Executor e1 : c.getOneOffExecutors()) {
if (e1.getCurrentExecutable() == this)
e = e1;
}
}
}
if (e != null) {
return e.doStop();
} else {
// nothing is building
return HttpResponses.forwardToPreviousPage();
}
}
/**
* Returns an input stream that reads from the log file.
* It will use a gzip-compressed log file (log.gz) if that exists.

0 comments on commit 05fadd7

Please sign in to comment.