From 03dce5af89430de4877032abbde056afb9a34c34 Mon Sep 17 00:00:00 2001 From: Victor Balakine Date: Wed, 7 Aug 2024 14:11:20 +0300 Subject: [PATCH] Removed Folder plugin dependency --- pom.xml | 144 +++++++++--------- .../business/GlobalBuildStatsBusiness.java | 43 +----- 2 files changed, 78 insertions(+), 109 deletions(-) diff --git a/pom.xml b/pom.xml index 1249512..f601007 100644 --- a/pom.xml +++ b/pom.xml @@ -1,80 +1,78 @@ - - 4.0.0 - - org.jenkins-ci.plugins - plugin - 4.86 - - + + 4.0.0 + + org.jenkins-ci.plugins + plugin + 4.86 + + - global-build-stats - ${changelist} - Jenkins global-build-stats plugin - hpi - https://github.com/jenkinsci/global-build-stats-plugin + global-build-stats + ${changelist} + Jenkins global-build-stats plugin + hpi + https://github.com/jenkinsci/global-build-stats-plugin - - - dhinske - David Hinske - david.hinske@gmx.net - - - fcamblor - Frederic Camblor - fcamblor+wikihudson@gmail.com - - - - - - org.jenkins-ci.plugins - cloudbees-folder - - - io.jenkins.plugins - ionicons-api - - - io.jenkins.plugins - flatpickr-api - 4.6.13-5.v534d8025a_a_59 - - - - - io.jenkins.tools.bom - bom-2.440.x - 3221.ve8f7b_fdd149d - import - pom - - - + + + dhinske + David Hinske + david.hinske@gmx.net + + + fcamblor + Frederic Camblor + fcamblor+wikihudson@gmail.com + + - - - repo.jenkins-ci.org - https://repo.jenkins-ci.org/public/ - - + + + io.jenkins.plugins + ionicons-api + + + io.jenkins.plugins + flatpickr-api + 4.6.13-5.v534d8025a_a_59 + + + + + + io.jenkins.tools.bom + bom-2.440.x + 3221.ve8f7b_fdd149d + import + pom + + + - - - repo.jenkins-ci.org - https://repo.jenkins-ci.org/public/ - - + + + repo.jenkins-ci.org + https://repo.jenkins-ci.org/public/ + + - - 999999-SNAPSHOT - 2.440.3 - + + + repo.jenkins-ci.org + https://repo.jenkins-ci.org/public/ + + - - scm:git:https://github.com/jenkinsci/global-build-stats-plugin.git - scm:git:git@github.com:jenkinsci/global-build-stats-plugin.git - https://github.com/jenkinsci/global-build-stats-plugin - ${scmTag} - + + 999999-SNAPSHOT + 2.440.3 + + + + scm:git:https://github.com/jenkinsci/global-build-stats-plugin.git + scm:git:git@github.com:jenkinsci/global-build-stats-plugin.git + https://github.com/jenkinsci/global-build-stats-plugin + ${scmTag} + diff --git a/src/main/java/hudson/plugins/global_build_stats/business/GlobalBuildStatsBusiness.java b/src/main/java/hudson/plugins/global_build_stats/business/GlobalBuildStatsBusiness.java index 6317938..e165c0e 100644 --- a/src/main/java/hudson/plugins/global_build_stats/business/GlobalBuildStatsBusiness.java +++ b/src/main/java/hudson/plugins/global_build_stats/business/GlobalBuildStatsBusiness.java @@ -1,9 +1,6 @@ package hudson.plugins.global_build_stats.business; -import hudson.model.TopLevelItem; -import hudson.model.AbstractProject; import hudson.model.Hudson; -import hudson.model.Item; import hudson.model.Job; import hudson.model.Run; import hudson.plugins.global_build_stats.GlobalBuildStatsPlugin; @@ -35,8 +32,6 @@ import org.jfree.ui.RectangleEdge; import org.jfree.ui.RectangleInsets; -import com.cloudbees.hudson.plugins.folder.Folder; - public class GlobalBuildStatsBusiness { private static final Logger LOGGER = Logger.getLogger(GlobalBuildStatsBusiness.class.getName()); @@ -96,18 +91,13 @@ public void recordBuildInfos() throws IOException { @Override public void changePluginStateBeforeSavingIt(GlobalBuildStatsPlugin plugin) { - List jobBuildResultsRead = new ArrayList(); - 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 AbstractProject) { - handleItem(jobBuildResultsRead, item); - } - } + List jobBuildResultsRead = Hudson.get().getAllItems(Job.class).stream() + // Cast to Job is necessary due to raw type returned from getAllItems + .map(job -> (Job) job) + .map(Job::getBuilds) + .flatMap(Collection::stream) + .map(JobBuildResultFactory.INSTANCE::createJobBuildResult) + .collect(java.util.stream.Collectors.toList()); plugin.getJobBuildResultsSharder().queueResultsToAdd( CollectionsUtil.minus(jobBuildResultsRead, plugin.getJobBuildResults())); @@ -115,12 +105,6 @@ public void changePluginStateBeforeSavingIt(GlobalBuildStatsPlugin plugin) { }); } - public void handleItem(List results, TopLevelItem item){ - if (item instanceof AbstractProject){ - addBuildsFrom(results, (AbstractProject)item); - } - } - public JFreeChart createChart(BuildStatConfiguration config){ List dimensions = createDataSetBuilder(config); return createChart(dimensions, config.getBuildStatTitle()); @@ -367,19 +351,6 @@ public List createDataSetBuilder(BuildStatConfi return dimensions; } - private static void addBuild(List jobBuildResultsRead, Run build){ - jobBuildResultsRead.add(JobBuildResultFactory.INSTANCE.createJobBuildResult(build)); - } - - private static void addBuildsFrom(List jobBuildResultsRead, AbstractProject project){ - List> builds = project.getBuilds(); - Iterator> buildIterator = builds.iterator(); - - while (buildIterator.hasNext()) { - addBuild(jobBuildResultsRead, buildIterator.next()); - } - } - protected static List mergeJobBuildResults(List existingJobResults, List jobResultsToMerge){ List mergedJobResultsList = new ArrayList(existingJobResults);