Skip to content
Permalink
Browse files

[JENKINS-21486] Verify core version

  • Loading branch information...
Vlatombe committed Apr 1, 2016
1 parent d57db1b commit 57e73a3575d4e1fb332e6e41afd282bdecf3d473
Showing with 23 additions and 0 deletions.
  1. +23 −0 core/src/main/java/hudson/PluginWrapper.java
@@ -408,6 +408,21 @@ private String getVersionOf(Manifest manifest) {
return "???";
}

/**
* Returns the required Jenkins core version of this plugin.
* @return the required Jenkins core version of this plugin.
* @since XXX
*/
@Exported
public @CheckForNull String getRequiredCoreVersion() {
String v = manifest.getMainAttributes().getValue("Jenkins-Version");
if (v!= null) return v;

v = manifest.getMainAttributes().getValue("Hudson-Version");
if (v!= null) return v;
return null;
}

/**
* Returns the version number of this plugin
*/
@@ -534,6 +549,14 @@ public boolean hasLicensesXml() {
* thrown if one or several mandatory dependencies doesn't exists.
*/
/*package*/ void resolvePluginDependencies() throws IOException {
String requiredCoreVersion = getRequiredCoreVersion();
if (requiredCoreVersion == null) {
throw new IOException(shortName + " doesn't declare required core version.");
} else {
if (Jenkins.getVersion().isOlderThan(new VersionNumber(requiredCoreVersion))) {
throw new IOException(shortName + " requires a more recent core version (" + requiredCoreVersion + ") than the current (" + Jenkins.getVersion() + ").");
}
}
List<String> missingDependencies = new ArrayList<String>();
List<String> obsoleteDependencies = new ArrayList<String>();
List<String> disabledDependencies = new ArrayList<String>();

0 comments on commit 57e73a3

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