Skip to content

Commit

Permalink
[FIXED JENKINS-19739] When installing a plugin and the needed depende…
Browse files Browse the repository at this point in the history
…ncies have compatibility issues, warn the user

(cherry picked from commit de9816e)
  • Loading branch information
stephenc authored and olivergondza committed Nov 6, 2013
1 parent c8e447b commit 32937e5
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
37 changes: 37 additions & 0 deletions core/src/main/java/hudson/model/UpdateSite.java
Expand Up @@ -728,6 +728,43 @@ public boolean isForNewerHudson() {
}
}

public VersionNumber getNeededDependenciesRequiredCore() {
VersionNumber versionNumber = null;
try {
versionNumber = requiredCore == null ? null : new VersionNumber(requiredCore);
} catch (NumberFormatException nfe) {
// unable to parse version
}
for (Plugin p: getNeededDependencies()) {
VersionNumber v = p.getNeededDependenciesRequiredCore();
if (versionNumber == null || v.isNewerThan(versionNumber)) versionNumber = v;
}
return versionNumber;
}

public boolean isNeededDependenciesForNewerJenkins() {
for (Plugin p: getNeededDependencies()) {
if (p.isForNewerHudson() || p.isNeededDependenciesForNewerJenkins()) return true;
}
return false;
}

/**
* If at least some of the plugin's needed dependencies are already installed, and the new version of the
* needed dependencies plugin have a "compatibleSinceVersion"
* value (i.e., it's only directly compatible with that version or later), this will check to
* see if the installed version is older than the compatible-since version. If it is older, it'll return false.
* If it's not older, or it's not installed, or it's installed but there's no compatibleSinceVersion
* specified, it'll return true.
*/
public boolean isNeededDependenciesCompatibleWithInstalledVersion() {
for (Plugin p: getNeededDependencies()) {
if (!p.isCompatibleWithInstalledVersion() || !p.isNeededDependenciesCompatibleWithInstalledVersion())
return false;
}
return true;
}

/**
* @deprecated as of 1.326
* Use {@link #deploy()}.
Expand Down
6 changes: 6 additions & 0 deletions core/src/main/resources/hudson/PluginManager/table.jelly
Expand Up @@ -103,6 +103,12 @@ THE SOFTWARE.
<j:if test="${p.isForNewerHudson()}">
<div class="compatWarning">${%coreWarning(p.requiredCore)}</div>
</j:if>
<j:if test="${!p.isNeededDependenciesCompatibleWithInstalledVersion()}">
<div class="compatWarning">${%depCompatWarning}</div>
</j:if>
<j:if test="${p.isNeededDependenciesForNewerJenkins()}">
<div class="compatWarning">${%depCoreWarning(p.getNeededDependenciesRequiredCore().toString())}</div>
</j:if>
</td>
<td class="pane"><st:out value="${p.version}" /></td>
<j:if test="${isUpdates}">
Expand Down
10 changes: 10 additions & 0 deletions core/src/main/resources/hudson/PluginManager/table.properties
Expand Up @@ -25,3 +25,13 @@ compatWarning=\
coreWarning=\
Warning: This plugin is built for Jenkins {0} or newer. \
It may or may not work in your Jenkins.
depCompatWarning=\
Warning: This plugin requires dependent plugins be upgraded \
and some of these dependent plugins are not compatible \
with the current installed version. Jobs using these \
dependent plugins may need to be reconfigured.
depCoreWarning=\
Warning: This plugin requires dependent plugins that are \
built for Jenkins {0} or newer. The dependent plugins may \
or may not work in your Jenkins and consenquently this \
plugin may or may not work in your Jenkins.

0 comments on commit 32937e5

Please sign in to comment.