use of hudson.model.Item in project workflow-cps-plugin by jenkinsci.
the class FlowDurabilityTest method createAndRunSleeperJob.
private WorkflowRun createAndRunSleeperJob(Jenkins jenkins, String jobName, FlowDurabilityHint durabilityHint, boolean resumeBlocked) throws Exception {
Item prev = jenkins.getItemByFullName(jobName);
if (prev != null) {
prev.delete();
}
WorkflowJob job = jenkins.createProject(WorkflowJob.class, jobName);
job.setResumeBlocked(resumeBlocked);
CpsFlowDefinition def = new CpsFlowDefinition("node {\n " + "sleep 30 \n" + "} \n" + "echo 'I like cheese'\n", false);
TestDurabilityHintProvider provider = Jenkins.get().getExtensionList(TestDurabilityHintProvider.class).get(0);
provider.registerHint(jobName, durabilityHint);
job.setDefinition(def);
WorkflowRun run = job.scheduleBuild2(0).getStartCondition().get();
story.j.waitForMessage("Sleeping for", run);
Assert.assertFalse(run.getExecution().isComplete());
Assert.assertFalse(((CpsFlowExecution) (run.getExecution())).done);
Assert.assertEquals(durabilityHint, run.getExecution().getDurabilityHint());
Assert.assertEquals("sleep", run.getExecution().getCurrentHeads().get(0).getDisplayFunctionName());
return run;
}
Aggregations