From 33dc1fb2b4d83fcd533c8f3a58dc9e2dde06c785 Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Fri, 1 Sep 2023 17:00:06 -0700 Subject: [PATCH] [JENKINS-71950] List plugins in deterministic order (#8453) List plugins in deterministic order --- core/src/main/java/hudson/init/InitStrategy.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/hudson/init/InitStrategy.java b/core/src/main/java/hudson/init/InitStrategy.java index be3312a1ff8a..95c31b94bf53 100644 --- a/core/src/main/java/hudson/init/InitStrategy.java +++ b/core/src/main/java/hudson/init/InitStrategy.java @@ -9,6 +9,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import java.util.Comparator; import java.util.Iterator; import java.util.List; import java.util.ServiceLoader; @@ -64,7 +65,11 @@ private void listPluginFiles(PluginManager pm, String extension, Collection pluginFiles = new ArrayList<>(); + pluginFiles.addAll(List.of(files)); + pluginFiles.sort(Comparator.comparing(File::getName)); + + all.addAll(pluginFiles); } /** @@ -76,15 +81,16 @@ private void listPluginFiles(PluginManager pm, String extension, Collection r) { String hplProperty = SystemProperties.getString("hudson.bundled.plugins"); if (hplProperty != null) { + List pluginFiles = new ArrayList<>(); for (String hplLocation : hplProperty.split(",")) { File hpl = new File(hplLocation.trim()); if (hpl.exists()) { - r.add(hpl); + pluginFiles.add(hpl); } else if (hpl.getName().contains("*")) { try { new DirScanner.Glob(hpl.getName(), null).scan(hpl.getParentFile(), new FileVisitor() { @Override public void visit(File f, String relativePath) throws IOException { - r.add(f); + pluginFiles.add(f); } }); } catch (IOException x) { @@ -94,6 +100,8 @@ protected void getBundledPluginsFromProperty(final List r) { LOGGER.warning("bundled plugin " + hplLocation + " does not exist"); } } + pluginFiles.sort(Comparator.comparing(File::getName)); + r.addAll(pluginFiles); } }