Skip to content

Commit

Permalink
Change discovery to recursive as per jenkinsci#14 (comment)
Browse files Browse the repository at this point in the history
  • Loading branch information
Petkov authored and Petkov committed Oct 7, 2019
1 parent 6c0ab3e commit 4752e41
Showing 1 changed file with 18 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.jfree.ui.RectangleEdge;
import org.jfree.ui.RectangleInsets;

import org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject;
import com.cloudbees.hudson.plugins.folder.Folder;

public class GlobalBuildStatsBusiness {
Expand Down Expand Up @@ -96,27 +97,32 @@ public void changePluginStateBeforeSavingIt(GlobalBuildStatsPlugin plugin) {

List<JobBuildResult> jobBuildResultsRead = new ArrayList<JobBuildResult>();
for (TopLevelItem item : Hudson.getInstance().getItems()) {
if (item instanceof Folder){
Folder f = (Folder)item;
for (TopLevelItem i : f.getItems()){
handleItem(jobBuildResultsRead,i);
}
}
if (item instanceof Job) {
handleItem(jobBuildResultsRead, item);
}
recursivelyAddBuilds(jobBuildResultsRead, item);
}

plugin.getJobBuildResultsSharder().queueResultsToAdd(
CollectionsUtil.<JobBuildResult>minus(jobBuildResultsRead, plugin.getJobBuildResults()));
}
});
}
public void handleItem(List<JobBuildResult> results, TopLevelItem item){

public void recursivelyAddBuilds(List<JobBuildResult> results, TopLevelItem item){
if (item instanceof Job){
addBuildsFrom(results, (Job)item);
addBuildsFrom(results, (Job) item);
}
if (item instanceof Folder){
Folder f = (Folder) item;
for (TopLevelItem i : f.getItems()){
recursivelyAddBuilds(results, i);
}
}

if (item instanceof WorkflowMultiBranchProject) {
WorkflowMultiBranchProject w = (WorkflowMultiBranchProject) item;
for (TopLevelItem i : w.getItems()) {
recursivelyAddBuilds(results, i);
}
}
}

public JFreeChart createChart(BuildStatConfiguration config){
Expand Down

0 comments on commit 4752e41

Please sign in to comment.