use of hudson.model.Executor in project workflow-job-plugin by jenkinsci.
the class WorkflowRunRestartTest method termAndKillInSidePanel.
@Issue("JENKINS-33721")
@Test
public void termAndKillInSidePanel() throws Exception {
story.then(r -> {
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
p.setDefinition(new CpsFlowDefinition("def seq = 0; retry (99) {zombie id: ++seq}", true));
WorkflowRun b = p.scheduleBuild2(0).waitForStart();
r.waitForMessage("[1] undead", b);
Executor ex = b.getExecutor();
assertNotNull(ex);
ex.interrupt();
r.waitForMessage("[1] bwahaha FlowInterruptedException #1", b);
ex.interrupt();
r.waitForMessage("[1] bwahaha FlowInterruptedException #2", b);
assertFalse(hasTermOrKillLink(b, "term"));
assertFalse(hasTermOrKillLink(b, "kill"));
r.waitForMessage("Click here to forcibly terminate running steps", b);
assertTrue(hasTermOrKillLink(b, "term"));
assertFalse(hasTermOrKillLink(b, "kill"));
b.doTerm();
r.waitForMessage("[2] undead", b);
r.waitForMessage("Click here to forcibly kill entire build", b);
assertTrue(hasTermOrKillLink(b, "term"));
assertTrue(hasTermOrKillLink(b, "kill"));
b.doKill();
r.waitForMessage("Hard kill!", b);
r.waitForCompletion(b);
r.assertBuildStatus(Result.ABORTED, b);
});
}
use of hudson.model.Executor in project hudson-2.x by hudson.
the class InstallToolCommand method install.
/**
* Performs an installation.
*/
private int install(ToolInstallation t, BuildIDs id, AbstractProject p) throws IOException, InterruptedException {
Run b = p.getBuildByNumber(Integer.parseInt(id.number));
if (b == null)
throw new AbortException("No such build: " + id.number);
Executor exec = b.getExecutor();
if (exec == null)
throw new AbortException(b.getFullDisplayName() + " is not building");
Node node = exec.getOwner().getNode();
if (t instanceof NodeSpecific) {
NodeSpecific n = (NodeSpecific) t;
t = (ToolInstallation) n.forNode(node, new StreamTaskListener(stderr));
}
if (t instanceof EnvironmentSpecific) {
EnvironmentSpecific e = (EnvironmentSpecific) t;
t = (ToolInstallation) e.forEnvironment(EnvVars.getRemote(channel));
}
stdout.println(t.getHome());
return 0;
}
use of hudson.model.Executor in project hudson-2.x by hudson.
the class WorkUnitContext method synchronizeEnd.
/**
* All the {@link Executor}s that jointly execute a {@link Task} call this method to synchronize on the end of the task.
*
* @throws InterruptedException
* If any of the member thread is interrupted while waiting for other threads to join, all
* the member threads will report {@link InterruptedException}.
*/
public void synchronizeEnd(Queue.Executable executable, Throwable problems, long duration) throws InterruptedException {
endLatch.synchronize();
// the main thread will send a notification
Executor e = Executor.currentExecutor();
WorkUnit wu = e.getCurrentWorkUnit();
if (wu.isMainWork()) {
if (problems == null) {
future.set(executable);
e.getOwner().taskCompleted(e, task, duration);
} else {
future.set(problems);
e.getOwner().taskCompletedWithProblems(e, task, duration, problems);
}
}
}
use of hudson.model.Executor in project hudson-2.x by hudson.
the class WorkUnitContext method abort.
/**
* When one of the work unit is aborted, call this method to abort all the other work units.
*/
public synchronized void abort(Throwable cause) {
if (cause == null)
throw new IllegalArgumentException();
// already aborted
if (aborted != null)
return;
aborted = cause;
startLatch.abort(cause);
endLatch.abort(cause);
Thread c = Thread.currentThread();
for (WorkUnit wu : workUnits) {
Executor e = wu.getExecutor();
if (e != null && e != c)
e.interrupt();
}
}
use of hudson.model.Executor in project workflow-cps-plugin by jenkinsci.
the class WorkflowTest method liveness.
private void liveness() {
assertFalse(jenkins().toComputer().isIdle());
Executor e = b.getOneOffExecutor();
assertNotNull(e);
assertEquals(e, b.getExecutor());
assertTrue(e.isActive());
/* TODO seems flaky:
assertFalse(e.isAlive());
*/
}
Aggregations