@Override public Collection<? extends Action> createFor(FlowExecutionOwner.Executable executable) { FlowExecutionOwner owner = executable.asFlowExecutionOwner(); if (owner != null) { FlowExecution exec = owner.getOrNull(); if (exec instanceof CpsFlowExecution && !exec.isComplete()) { CpsFlowExecution e = (CpsFlowExecution) exec; List<Action> actions = new ArrayList<>(); actions.add(new CpsThreadDumpAction(e)); // TODO cf. comment in CpsFlowExecution#pause if (!(executable instanceof AccessControlled) || ((AccessControlled) executable).hasPermission(Item.CANCEL)) { actions.add(new PauseUnpauseAction(e)); } return actions; } } return Collections.emptySet(); }
SemaphoreStep.waitForStart("y/1", b); CpsThreadDump td = b.getAction(CpsThreadDumpAction.class).threadDumpSynchronous(); td.print(System.out);
@Test public void load() throws Exception { j.jenkins.getWorkspaceFor(p).child("lib.groovy").write("def m() {semaphore 'here'}; this", null); p.setDefinition(new CpsFlowDefinition("def lib; node {lib = load 'lib.groovy'}; lib.m()", true)); WorkflowRun b = p.scheduleBuild2(0).waitForStart(); SemaphoreStep.waitForStart("here/1", b); CpsThreadDump td = b.getAction(CpsThreadDumpAction.class).threadDumpSynchronous(); td.print(System.out); assertStackTrace(td.getThreads().get(0), "DSL.semaphore(waiting on here/1)", "Script1.m(Script1.groovy:1)", "WorkflowScript.run(WorkflowScript:1)"); }
fail("not sure why CpsThreadDumpAction was missing here"); CpsThreadDump td = action.threadDumpSynchronous(); td.print(System.out);