use of io.jenkins.blueocean.rest.impl.pipeline.NodeGraphBuilder in project blueocean-plugin by jenkinsci.
the class PipelinePluginAnalytics method onCompleted.
@Override
public void onCompleted(WorkflowRun workflowRun, @Nonnull TaskListener listener) {
Analytics analytics = Analytics.get();
if (analytics == null) {
return;
}
// Tally up all the steps used in this run
Tally tally = new Tally();
NodeGraphBuilder builder = NodeGraphBuilder.NodeGraphBuilderFactory.getInstance(workflowRun);
builder.getPipelineNodeSteps(new Link("steps/")).forEach(step -> {
tally.count(step.getStepType());
});
boolean isDeclarative = workflowRun.getParent().getAction(DeclarativeJobAction.class) != null;
Result result = workflowRun.getResult();
String resultAsString = result != null ? result.toString() : "UNKNOWN";
// Send event for each step used in this run
tally.get().forEach((key, value) -> {
ImmutableMap.Builder<String, Object> props = ImmutableMap.builder();
props.put("type", key);
props.put("timesUsed", value);
props.put("isDeclarative", isDeclarative);
props.put("runResult", resultAsString);
analytics.track(new TrackRequest("pipeline_step_used", props.build()));
});
}
Aggregations