use of hudson.model.Executor in project workflow-cps-plugin by jenkinsci.
the class CpsFlowDefinition2Test method endlessRecursion.
/**
* Verify that we kill endlessly recursive CPS code cleanly.
*/
@Test
public void endlessRecursion() throws Exception {
// Sidestep false failures specific to a few Windows build environments.
Assume.assumeTrue(!Functions.isWindows());
String script = "def getThing(){return thing == null}; \n" + "node { echo getThing(); } ";
WorkflowJob job = jenkins.createProject(WorkflowJob.class);
job.setDefinition(new CpsFlowDefinition(script, true));
// Should have failed with error about excessive recursion depth
WorkflowRun r = jenkins.assertBuildStatus(Result.FAILURE, job.scheduleBuild2(0).get());
jenkins.assertLogContains("look for unbounded recursion", r);
Assert.assertTrue("No queued FlyWeightTask for job should remain after failure", jenkins.jenkins.getQueue().isEmpty());
for (Computer c : jenkins.jenkins.getComputers()) {
for (Executor ex : c.getExecutors()) {
if (ex.isBusy()) {
fail(ex.getCurrentExecutable().toString());
}
}
}
}
use of hudson.model.Executor in project workflow-cps-plugin by jenkinsci.
the class FlowDurabilityTest method assertNoTasksRunning.
private static void assertNoTasksRunning(Jenkins j) {
j.getQueue().maintain();
assert j.getQueue().isEmpty();
Computer[] computerList = j.getComputers();
for (Computer c : computerList) {
List<Executor> executors = c.getExecutors();
for (Executor ex : executors) {
if (ex.isBusy()) {
Assert.fail("Computer " + c + " has an Executor " + ex + " still running a task: " + ex.getCurrentWorkUnit());
}
}
}
}
use of hudson.model.Executor in project phabricator-jenkins-plugin by uber.
the class PhabricatorBuildWrapper method preCheckout.
/**
* Abort running builds when new build referencing same revision is scheduled to run
*/
@Override
public void preCheckout(AbstractBuild build, Launcher launcher, BuildListener listener) throws IOException, InterruptedException {
String abortOnRevisionId = getAbortOnRevisionId(build);
// If ABORT_ON_REVISION_ID is available
if (!CommonUtils.isBlank(abortOnRevisionId)) {
// Create a cause of interruption
PhabricatorCauseOfInterruption causeOfInterruption = new PhabricatorCauseOfInterruption(build.getUrl());
Run upstreamRun = getUpstreamRun(build);
// Get the running builds that were scheduled before the current one
RunList<AbstractBuild> runningBuilds = (RunList<AbstractBuild>) build.getProject().getBuilds();
for (AbstractBuild runningBuild : runningBuilds) {
Executor executor = runningBuild.getExecutor();
Run runningBuildUpstreamRun = getUpstreamRun(runningBuild);
// Find builds triggered with the same ABORT_ON_REVISION_ID_FIELD
if (runningBuild.isBuilding() && runningBuild.number < build.number && abortOnRevisionId.equals(getAbortOnRevisionId(runningBuild)) && (upstreamRun == null || runningBuildUpstreamRun == null || !upstreamRun.equals(runningBuildUpstreamRun)) && executor != null) {
// Abort the builds
executor.interrupt(Result.ABORTED, causeOfInterruption);
}
}
}
}
Aggregations