Search in sources :

Example 16 with Executor

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());
            }
        }
    }
}
Also used : Executor(hudson.model.Executor) Computer(hudson.model.Computer) WorkflowJob(org.jenkinsci.plugins.workflow.job.WorkflowJob) WorkflowRun(org.jenkinsci.plugins.workflow.job.WorkflowRun) Test(org.junit.Test)

Example 17 with Executor

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());
            }
        }
    }
}
Also used : Executor(hudson.model.Executor) Computer(hudson.model.Computer)

Example 18 with Executor

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);
            }
        }
    }
}
Also used : RunList(hudson.util.RunList) Executor(hudson.model.Executor) AbstractBuild(hudson.model.AbstractBuild) Run(hudson.model.Run)

Aggregations

Executor (hudson.model.Executor)18 Computer (hudson.model.Computer)8 Node (hudson.model.Node)5 Test (org.junit.Test)5 AbortException (hudson.AbortException)2 FilePath (hudson.FilePath)2 Run (hudson.model.Run)2 CpsFlowDefinition (org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition)2 WorkflowJob (org.jenkinsci.plugins.workflow.job.WorkflowJob)2 WorkflowRun (org.jenkinsci.plugins.workflow.job.WorkflowRun)2 Issue (org.jvnet.hudson.test.Issue)2 AbstractBuild (hudson.model.AbstractBuild)1 EnvironmentSpecific (hudson.model.EnvironmentSpecific)1 Queue (hudson.model.Queue)1 StreamBuildListener (hudson.model.StreamBuildListener)1 ExecutorChunk (hudson.model.queue.MappingWorksheet.ExecutorChunk)1 Mapping (hudson.model.queue.MappingWorksheet.Mapping)1 WorkChunk (hudson.model.queue.MappingWorksheet.WorkChunk)1 Promotion (hudson.plugins.promoted_builds.Promotion)1 NodeSpecific (hudson.slaves.NodeSpecific)1