Skip to content
Permalink
Browse files

[FIXED JENKINS-37041] Ensure that detached plugins are always at leas…

…t their minimum version

(cherry picked from commit 2a450e5)
  • Loading branch information
stephenc authored and olivergondza committed Jul 28, 2016
1 parent 943d820 commit 6ea7883fed497b68eec9f89ec89082edf1b39ce5
Showing with 38 additions and 0 deletions.
  1. +10 −0 core/src/main/java/hudson/ClassicPluginStrategy.java
  2. +28 −0 core/src/main/java/hudson/PluginManager.java
@@ -401,6 +401,16 @@ public String getShortName() {
public VersionNumber getSplitWhen() {
return splitWhen;
}

/**
* Gets the minimum required version for the current version of Jenkins.
*
* @return the minimum required version for the current version of Jenkins.
* @sice 2.16
*/
public VersionNumber getRequireVersion() {
return new VersionNumber(requireVersion);
}
}

private static final List<DetachedPlugin> DETACHED_LIST = Collections.unmodifiableList(Arrays.asList(
@@ -715,6 +715,34 @@ public boolean accept(File dir, String name) {
new Object[] {lastExecVersion, Jenkins.VERSION, loadedDetached});

InstallUtil.saveLastExecVersion();
} else {
final Set<ClassicPluginStrategy.DetachedPlugin> forceUpgrade = new HashSet<>();
for (ClassicPluginStrategy.DetachedPlugin p : ClassicPluginStrategy.getDetachedPlugins()) {
VersionNumber installedVersion = getPluginVersion(rootDir, p.getShortName());
VersionNumber requireVersion = p.getRequireVersion();
if (installedVersion != null && installedVersion.isOlderThan(requireVersion)) {
LOGGER.log(Level.WARNING,
"Detached plugin {0} found at version {1}, required minimum version is {2}",
new Object[]{p.getShortName(), installedVersion, requireVersion});
forceUpgrade.add(p);
}
}
if (!forceUpgrade.isEmpty()) {
Set<String> loadedDetached = loadPluginsFromWar("/WEB-INF/detached-plugins", new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
name = normalisePluginName(name);
for (ClassicPluginStrategy.DetachedPlugin detachedPlugin : forceUpgrade) {
if (detachedPlugin.getShortName().equals(name)) {
return true;
}
}
return false;
}
});
LOGGER.log(INFO, "Upgraded detached plugins (and dependencies): {0}",
new Object[]{loadedDetached});
}
}
}

0 comments on commit 6ea7883

Please sign in to comment.
You can’t perform that action at this time.