Do not downgrade installed plugins when loading detached plugins
@@ -650,7 +650,17 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas
continue;
}
- String artifactId = dependencyToken.split(":")[0];
+ String[] artifactIdVersionPair = dependencyToken.split(":");
+ String artifactId = artifactIdVersionPair[0];
+ VersionNumber dependencyVersion = new VersionNumber(artifactIdVersionPair[1]);
+
+ PluginManager manager = Jenkins.getActiveInstance().getPluginManager();
+ VersionNumber installedVersion = manager.getPluginVersion(manager.rootDir, artifactId);
+ if (installedVersion != null && installedVersion.isNewerThan(dependencyVersion)) {
+ // Do not downgrade dependencies that are already installed.
+ continue;
+ }
+
URL dependencyURL = context.getResource(fromPath + "/" + artifactId + ".hpi");
if (dependencyURL == null) {
