Skip to content

Commit b528eea

Browse files
authored
Merge pull request #6 from jenkinsci/get-handler
avoid using stapler new
2 parents 459b9d5 + b947e12 commit b528eea

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

src/main/java/io/jenkins/plugins/agent_build_history/AgentBuildHistory.java

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
import jenkins.util.Timer;
2020
import org.jenkinsci.plugins.workflow.cps.nodes.StepStartNode;
2121
import org.jenkinsci.plugins.workflow.flow.FlowExecution;
22-
import org.jenkinsci.plugins.workflow.graph.FlowGraphWalker;
2322
import org.jenkinsci.plugins.workflow.graph.FlowNode;
23+
import org.jenkinsci.plugins.workflow.graphanalysis.DepthFirstScanner;
2424
import org.jenkinsci.plugins.workflow.job.WorkflowRun;
2525
import org.jenkinsci.plugins.workflow.steps.StepDescriptor;
2626
import org.jenkinsci.plugins.workflow.support.actions.WorkspaceActionImpl;
@@ -62,6 +62,12 @@ public Computer getComputer() {
6262
return computer;
6363
}
6464

65+
public RunListTable getHandler() {
66+
RunListTable runListTable = new RunListTable();
67+
runListTable.setRuns(getExecutions());
68+
return runListTable;
69+
}
70+
6571
private static void load(Computer computer) {
6672
Set<AgentExecution> executions = agentExecutions.get(computer);
6773
Node node = computer.getNode();
@@ -80,19 +86,15 @@ private static void load(Computer computer) {
8086
if (flowExecution != null) {
8187
AgentExecution execution = new AgentExecution(wfr);
8288
boolean matchesNode = false;
83-
FlowGraphWalker walker = new FlowGraphWalker(flowExecution);
84-
for (FlowNode flowNode : walker) {
85-
if (flowNode instanceof StepStartNode) {
89+
for (FlowNode flowNode : new DepthFirstScanner().allNodes(flowExecution)) {
90+
for (WorkspaceActionImpl action : flowNode.getActions(WorkspaceActionImpl.class)) {
8691
StepStartNode startNode = (StepStartNode) flowNode;
8792
StepDescriptor descriptor = startNode.getDescriptor();
8893
if (descriptor instanceof ExecutorStep.DescriptorImpl) {
89-
WorkspaceActionImpl action = flowNode.getAction(WorkspaceActionImpl.class);
90-
if (action != null) {
91-
String nodeName = action.getNode();
92-
if (node.getNodeName().equals(nodeName)) {
93-
matchesNode = true;
94-
execution.addFlowNode(flowNode);
95-
}
94+
String nodeName = action.getNode();
95+
if (node.getNodeName().equals(nodeName)) {
96+
matchesNode = true;
97+
execution.addFlowNode(flowNode);
9698
}
9799
}
98100
}

src/main/resources/io/jenkins/plugins/agent_build_history/AgentBuildHistory/index.jelly

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@
2727

2828
<t:setIconSize/>
2929
<st:adjunct includes="io.jenkins.plugins.agent_build_history.agentBuildHistory" />
30-
<j:new var="handler" className="io.jenkins.plugins.agent_build_history.RunListTable" classLoader="${it.class.classLoader}"/>
31-
${handler.setRuns(it.executions)}
32-
<l:progressiveRendering handler="${handler}" callback="abhDisplayExtendedBuildHistory"/>
30+
<l:progressiveRendering handler="${it.handler}" callback="abhDisplayExtendedBuildHistory"/>
3331
<table class="jenkins-table ${iconSize == '16x16' ? 'jenkins-table--small' : iconSize == '24x24' ? 'jenkins-table--medium' : ''}"
3432
id="projectStatus" style="display: none;" data-icon-size-class="${iconSizeClass}"
3533
data-show-nodes-text="${%Show nodes}" data-hide-nodes-text="${%Hide nodes}">

0 commit comments

Comments
 (0)