mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-13 12:02:20 +00:00
[JENKINS-71950] List plugins in deterministic order (#8453)
List plugins in deterministic order
This commit is contained in:
1 parent
4468290dda
commit
33dc1fb2b4
1 file changed
+11
-3
@@ -9,6 +9,7 @@ import java.io.IOException;
|
||||
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 @@ public class InitStrategy {
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,15 +81,16 @@ public class InitStrategy {
|
||||
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) {
|
||||
@@ -94,6 +100,8 @@ public class InitStrategy {
|
||||
LOGGER.warning("bundled plugin " + hplLocation + " does not exist");
|
||||
}
|
||||
}
|
||||
pluginFiles.sort(Comparator.comparing(File::getName));
|
||||
r.addAll(pluginFiles);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user