Search in sources :

Example 6 with FlowExecutionOwner

use of org.jenkinsci.plugins.workflow.flow.FlowExecutionOwner in project workflow-cps-plugin by jenkinsci.

the class CpsScript method $build.

@CheckForNull
public Run<?, ?> $build() throws IOException {
    FlowExecutionOwner owner = execution.getOwner();
    Queue.Executable qe = owner.getExecutable();
    if (qe instanceof Run) {
        return (Run) qe;
    } else {
        return null;
    }
}
Also used : FlowExecutionOwner(org.jenkinsci.plugins.workflow.flow.FlowExecutionOwner) Run(hudson.model.Run) Queue(hudson.model.Queue) CheckForNull(javax.annotation.CheckForNull)

Example 7 with FlowExecutionOwner

use of org.jenkinsci.plugins.workflow.flow.FlowExecutionOwner in project workflow-cps-plugin by jenkinsci.

the class RunningFlowActions method createFor.

@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();
}
Also used : AccessControlled(hudson.security.AccessControlled) Action(hudson.model.Action) FlowExecutionOwner(org.jenkinsci.plugins.workflow.flow.FlowExecutionOwner) FlowExecution(org.jenkinsci.plugins.workflow.flow.FlowExecution) ArrayList(java.util.ArrayList)

Aggregations

FlowExecutionOwner (org.jenkinsci.plugins.workflow.flow.FlowExecutionOwner)7 FlowExecution (org.jenkinsci.plugins.workflow.flow.FlowExecution)3 ArrayList (java.util.ArrayList)2 CheckForNull (javax.annotation.CheckForNull)2 Test (org.junit.Test)2 EnvVars (hudson.EnvVars)1 Action (hudson.model.Action)1 Queue (hudson.model.Queue)1 Run (hudson.model.Run)1 TaskListener (hudson.model.TaskListener)1 AccessControlled (hudson.security.AccessControlled)1 CopyOnWriteList (hudson.util.CopyOnWriteList)1 LogTaskListener (hudson.util.LogTaskListener)1 Field (java.lang.reflect.Field)1 Arrays.asList (java.util.Arrays.asList)1 List (java.util.List)1 CpsFlowExecution (org.jenkinsci.plugins.workflow.cps.CpsFlowExecution)1 ThreadInfo (org.jenkinsci.plugins.workflow.cps.CpsThreadDump.ThreadInfo)1 FlowExecutionList (org.jenkinsci.plugins.workflow.flow.FlowExecutionList)1 WorkflowRun (org.jenkinsci.plugins.workflow.job.WorkflowRun)1