Skip to content
Browse files

[JENKINS-48899] Do not downgrade detached plugins when upgrading Jenk…

…ins (#3229)

* Reproduce JENKINS-48899

* Do not downgrade installed detached plugins
  • Loading branch information...
dwnusbaum authored and oleg-nenashev committed Jan 21, 2018
1 parent 4cbeed7 commit d6298979581da67336f077cda9fd218eb790bdb3
@@ -706,13 +706,14 @@ public boolean accept(File dir, String name) {
// 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);

@@ -120,6 +120,25 @@ public void upgradeFromJenkins2WithOlderDependency() {

public void upgradeFromJenkins2WithNewerPlugin() {
// @LocalData has command-launcher 1.2 installed, which should not be downgraded to the detached version: 1.0.
VersionNumber since = new VersionNumber("2.0");
rr.then(r -> {
List<DetachedPlugin> detachedPlugins = ClassicPluginStrategy.getDetachedPlugins(since);
assertThat("Plugins have been detached since the pre-upgrade version",
detachedPlugins.size(), greaterThan(1));
assertThat("Plugins detached between the pre-upgrade version and the current version should be installed",
getInstalledDetachedPlugins(r, detachedPlugins).size(), equalTo(detachedPlugins.size()));
Plugin commandLauncher = r.jenkins.getPlugin("command-launcher");
assertThat("Installed detached plugins should not be overwritten by older versions",
commandLauncher.getWrapper().getVersionNumber(), equalTo(new VersionNumber("1.2")));

public void newInstallation() {
rr.then(r -> {
Binary file not shown.

0 comments on commit d629897

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