[JENKINS-48899] Do not downgrade detached plugins when upgrading Jenkins (#3229)

* Reproduce JENKINS-48899

* Do not downgrade installed detached plugins

(cherry picked from commit d629897958)
This commit is contained in:
Devin Nusbaum authored and Oliver Gondža committed 2018-01-31 11:41:51 +01:00
1 parent bed6ccd719
commit 7b6c86dc58
3 files changed
+25 -5

No files matched your search

+6 -5
View File
@@ -705,13 +705,14 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas
// If this was a plugin that was detached some time in the past i.e. not just one of the
// plugins that was bundled "for fun".
if (ClassicPluginStrategy.isDetachedPlugin(name)) {
// If it's already installed and the installed version is older
// than the bundled version, then we upgrade. The bundled version is the min required version
// for "this" version of Jenkins, so we must upgrade.
VersionNumber installedVersion = getPluginVersion(rootDir, name);
VersionNumber bundledVersion = getPluginVersion(dir, name);
if (installedVersion != null && bundledVersion != null && installedVersion.isOlderThan(bundledVersion)) {
return true;
// If the plugin is already installed, we need to decide whether to replace it with the bundled version.
if (installedVersion != null && bundledVersion != null) {
// If the installed version is older than the bundled version, then it MUST be upgraded.
// If the installed version is newer than the bundled version, then it MUST NOT be upgraded.
// If the versions are equal we just keep the installed version.
return installedVersion.isOlderThan(bundledVersion);
}
}