Skip to content

Commit

Permalink
[JENKINS-71950] List plugins in deterministic order (#8453)
Browse files Browse the repository at this point in the history
List plugins in deterministic order
  • Loading branch information
basil committed Sep 2, 2023
1 parent 4468290 commit 33dc1fb
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions core/src/main/java/hudson/init/InitStrategy.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -64,7 +65,11 @@ private void listPluginFiles(PluginManager pm, String extension, Collection<File
if (files == null)
throw new IOException("Jenkins is unable to create " + pm.rootDir + "\nPerhaps its security privilege is insufficient");

all.addAll(Arrays.asList(files));
List<File> pluginFiles = new ArrayList<>();
pluginFiles.addAll(List.of(files));
pluginFiles.sort(Comparator.comparing(File::getName));

all.addAll(pluginFiles);
}

/**
Expand All @@ -76,15 +81,16 @@ private void listPluginFiles(PluginManager pm, String extension, Collection<File
protected void getBundledPluginsFromProperty(final List<File> r) {
String hplProperty = SystemProperties.getString("hudson.bundled.plugins");
if (hplProperty != null) {
List<File> 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) {
Expand All @@ -94,6 +100,8 @@ protected void getBundledPluginsFromProperty(final List<File> r) {
LOGGER.warning("bundled plugin " + hplLocation + " does not exist");
}
}
pluginFiles.sort(Comparator.comparing(File::getName));
r.addAll(pluginFiles);
}
}

Expand Down

0 comments on commit 33dc1fb

Please sign in to comment.