use of org.jenkinsci.plugins.workflow.steps.StepDescriptor 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;
}
use of org.jenkinsci.plugins.workflow.steps.StepDescriptor 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";
}
use of org.jenkinsci.plugins.workflow.steps.StepDescriptor in project blueocean-plugin by jenkinsci.
the class PipelineMetadataService method doPipelineStepMetadata.
/**
* Function to return all step descriptors present in the system when accessed through the REST API
*/
@GET
@TreeResponse
public ExportedPipelineFunction[] doPipelineStepMetadata() {
List<ExportedPipelineFunction> pd = new ArrayList<>();
for (StepDescriptor d : StepDescriptor.all()) {
if (includeStep(d)) {
ExportedPipelineStep step = getStepMetadata(d);
if (step != null) {
pd.add(step);
}
}
}
List<Descriptor<?>> metaStepDescriptors = new ArrayList<Descriptor<?>>();
populateMetaSteps(metaStepDescriptors, Builder.class);
populateMetaSteps(metaStepDescriptors, Publisher.class);
for (Descriptor<?> d : metaStepDescriptors) {
ExportedPipelineFunction metaStep = getStepMetadata(d);
if (metaStep != null) {
pd.add(metaStep);
}
}
return pd.toArray(new ExportedPipelineFunction[pd.size()]);
}
Aggregations