Skip to content
Permalink
Browse files

JENKINS-33308 - automatically install previously bundled dependencies

for plugins that depend on old Jenkins versions
  • Loading branch information...
kzantow committed Mar 15, 2016
1 parent 3edb9fd commit 5e8bb98ee071c67046fdd3a09d2021c272560207
@@ -259,6 +259,19 @@ private static Manifest loadLinkedManifest(File archive) throws IOException {
return new PluginWrapper(pluginManager, archive, manifest, baseResourceURL,
createClassLoader(paths, dependencyLoader, atts), disableFile, dependencies, optionalDependencies);
}

/**
* Returns all the bundled plugin dependencies for a particular Jenkins version
*/
public static List<PluginWrapper.Dependency> getPreviouslyBundledDependencies(String jenkinsVersion) {
List<PluginWrapper.Dependency> out = new ArrayList<>();
for (DetachedPlugin detached : DETACHED_LIST) {
if (jenkinsVersion == null || jenkinsVersion.equals("null") || new VersionNumber(jenkinsVersion).compareTo(detached.splitWhen) <= 0) {
out.add(new PluginWrapper.Dependency(detached.shortName + ':' + detached.requireVersion));
}
}
return out;
}

@Deprecated
protected ClassLoader createClassLoader(List<File> paths, ClassLoader parent) throws IOException {
@@ -1140,7 +1140,9 @@ public HttpResponse doInstallPlugins(StaplerRequest req) throws IOException {
String pluginName = n.substring(0, index);
String siteName = n.substring(index + 1);
UpdateSite.Plugin plugin = getPlugin(pluginName, siteName);
// TODO: Someone that understands what the following logic is about, please add a comment.
// There could be cases like:
// 'plugin.ambiguous.updatesite' where both
// 'plugin' @ 'ambigiuous.updatesite' and 'plugin.ambiguous' @ 'updatesite' resolve to valid plugins
if (plugin != null) {
if (p != null) {
throw new Failure("Ambiguous plugin: " + n);
@@ -1150,9 +1152,23 @@ public HttpResponse doInstallPlugins(StaplerRequest req) throws IOException {
index = n.indexOf('.', index + 1);
}
}

if (p == null) {
throw new Failure("No such plugin: " + n);
}

// JENKINS-33308 - automatically install implied/previously bundled dependencies for older plugins that may need them
for(PluginWrapper.Dependency previouslyBundledDependency : ClassicPluginStrategy.getPreviouslyBundledDependencies(p.requiredCore)) {
// if they aren't already installed, note the dependencies show 'need restart' messages if installed multiple times
// but it can't be prevented here
if(getPlugin(previouslyBundledDependency.shortName) == null) {
// as these are basically jenkins core, these should always be installed from the default update center
UpdateSite.Plugin previouslyBundledPlugin = getPlugin(previouslyBundledDependency.shortName, UpdateCenter.ID_DEFAULT);
Future<UpdateCenter.UpdateCenterJob> jobFuture = previouslyBundledPlugin.deploy(dynamicLoad, correlationId);
installJobs.add(jobFuture);
}
}

Future<UpdateCenter.UpdateCenterJob> jobFuture = p.deploy(dynamicLoad, correlationId);
installJobs.add(jobFuture);
}

0 comments on commit 5e8bb98

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