Search in sources :

Example 1 with StepNode

use of org.jenkinsci.plugins.workflow.graph.StepNode in project blueocean-plugin by jenkinsci.

the class PipelineEventListener method newMessage.

private Message newMessage(PipelineEventChannel.Event event, FlowNode flowNode, Collection<String> branch) {
    Message message = newMessage(event, flowNode.getExecution());
    message.set(PipelineEventChannel.EventProps.pipeline_step_flownode_id, flowNode.getId());
    message.set(PipelineEventChannel.EventProps.pipeline_context, toPath(branch));
    if (currentStageName != null) {
        message.set(PipelineEventChannel.EventProps.pipeline_step_stage_name, currentStageName.get(flowNode.getExecution()));
        message.set(PipelineEventChannel.EventProps.pipeline_step_stage_id, currentStageId.get(flowNode.getExecution()));
    }
    if (flowNode instanceof StepNode) {
        StepNode stepNode = (StepNode) flowNode;
        StepDescriptor stepDescriptor = stepNode.getDescriptor();
        if (stepDescriptor != null) {
            message.set(PipelineEventChannel.EventProps.pipeline_step_name, stepDescriptor.getFunctionName());
            // TODO: Better event choice, more granularity - like only firing when this results in a status change
            if (stepDescriptor instanceof ExecutorStep.DescriptorImpl) {
                Run<?, ?> run = runFor(flowNode.getExecution());
                if (run != null) {
                    publishJobEvent(run, Events.JobChannel.job_run_started);
                }
                if (flowNode.getPersistentAction(QueueItemAction.class) != null) {
                    // Needed because this is expected everywhere apparently.
                    message.set(PipelineEventChannel.EventProps.pipeline_step_is_paused, String.valueOf(false));
                }
            }
        }
    }
    if (flowNode instanceof StepAtomNode) {
        Run<?, ?> run = runFor(flowNode.getExecution());
        if (run != null) {
            boolean pausedForInputStep = PipelineNodeUtil.isPausedForInputStep((StepAtomNode) flowNode, run.getAction(InputAction.class));
            if (pausedForInputStep) {
                // Fire job event to tell we are paused
                // We will publish on the job channel
                publishJobEvent(run, Events.JobChannel.job_run_paused);
            }
            message.set(PipelineEventChannel.EventProps.pipeline_step_is_paused, String.valueOf(pausedForInputStep));
        }
    }
    return message;
}
Also used : StepNode(org.jenkinsci.plugins.workflow.graph.StepNode) SimpleMessage(org.jenkinsci.plugins.pubsub.SimpleMessage) RunMessage(org.jenkinsci.plugins.pubsub.RunMessage) Message(org.jenkinsci.plugins.pubsub.Message) QueueItemAction(org.jenkinsci.plugins.workflow.actions.QueueItemAction) InputAction(org.jenkinsci.plugins.workflow.support.steps.input.InputAction) StepDescriptor(org.jenkinsci.plugins.workflow.steps.StepDescriptor) StepAtomNode(org.jenkinsci.plugins.workflow.cps.nodes.StepAtomNode)

Example 2 with StepNode

use of org.jenkinsci.plugins.workflow.graph.StepNode in project blueocean-plugin by jenkinsci.

the class PipelineStepImpl method getStepType.

@Override
public String getStepType() {
    FlowNode flowNode = this.node.getNode();
    if (flowNode instanceof StepNode && !(flowNode instanceof StepEndNode)) {
        StepNode stepNode = (StepNode) flowNode;
        StepDescriptor descriptor = stepNode.getDescriptor();
        if (descriptor != null)
            return descriptor.getId();
    }
    return "unknown";
}
Also used : StepNode(org.jenkinsci.plugins.workflow.graph.StepNode) StepDescriptor(org.jenkinsci.plugins.workflow.steps.StepDescriptor) StepEndNode(org.jenkinsci.plugins.workflow.cps.nodes.StepEndNode) FlowNode(org.jenkinsci.plugins.workflow.graph.FlowNode)

Aggregations

StepNode (org.jenkinsci.plugins.workflow.graph.StepNode)2 StepDescriptor (org.jenkinsci.plugins.workflow.steps.StepDescriptor)2 Message (org.jenkinsci.plugins.pubsub.Message)1 RunMessage (org.jenkinsci.plugins.pubsub.RunMessage)1 SimpleMessage (org.jenkinsci.plugins.pubsub.SimpleMessage)1 QueueItemAction (org.jenkinsci.plugins.workflow.actions.QueueItemAction)1 StepAtomNode (org.jenkinsci.plugins.workflow.cps.nodes.StepAtomNode)1 StepEndNode (org.jenkinsci.plugins.workflow.cps.nodes.StepEndNode)1 FlowNode (org.jenkinsci.plugins.workflow.graph.FlowNode)1 InputAction (org.jenkinsci.plugins.workflow.support.steps.input.InputAction)1