diff --git a/core/src/main/java/hudson/PluginWrapper.java b/core/src/main/java/hudson/PluginWrapper.java index b81dbd92a5e560209e222a5bb11e3af32059a821..dfbc1b1806d1520f74b9e36dc4852b26a1c759d1 100644 --- a/core/src/main/java/hudson/PluginWrapper.java +++ b/core/src/main/java/hudson/PluginWrapper.java @@ -26,6 +26,7 @@ package hudson; import com.google.common.collect.ImmutableSet; import hudson.PluginManager.PluginInstanceStore; +import hudson.model.AdministrativeMonitor; import hudson.model.Api; import hudson.model.ModelObject; import jenkins.YesNoMaybe; @@ -53,6 +54,8 @@ import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.LogFactory; import org.kohsuke.stapler.HttpResponse; import org.kohsuke.stapler.HttpResponses; +import org.kohsuke.stapler.StaplerRequest; +import org.kohsuke.stapler.StaplerResponse; import org.kohsuke.stapler.export.Exported; import org.kohsuke.stapler.export.ExportedBean; import org.kohsuke.stapler.interceptor.RequirePOST; @@ -560,13 +563,16 @@ public class PluginWrapper implements Comparable, ModelObject { PluginWrapper dependency = parent.getPlugin(d.shortName); if (dependency == null) { missingDependencies.add(d); + NOTICE.addErrorMessage(Messages.PluginWrapper_admonitor_MissingDependency(getLongName(), d.shortName)); } else { if (dependency.isActive()) { if (isDependencyObsolete(d, dependency)) { obsoleteDependencies.add(d); + NOTICE.addErrorMessage(Messages.PluginWrapper_admonitor_ObsoleteDependency(getLongName(), dependency.getLongName(), d.version)); } } else { disabledDependencies.add(d); + NOTICE.addErrorMessage(Messages.PluginWrapper_admonitor_DisabledDependency(getLongName(), dependency.getLongName())); } } @@ -577,6 +583,7 @@ public class PluginWrapper implements Comparable, ModelObject { if (dependency != null && dependency.isActive()) { if (isDependencyObsolete(d, dependency)) { obsoleteDependencies.add(d); + NOTICE.addErrorMessage(Messages.PluginWrapper_admonitor_ObsoleteDependency(getLongName(), dependency.getLongName(), d.version)); } else { dependencies.add(d); } @@ -612,6 +619,7 @@ public class PluginWrapper implements Comparable, ModelObject { private void checkRequiredCoreVersion(String requiredCoreVersion) throws IOException { if (Jenkins.getVersion().isOlderThan(new VersionNumber(requiredCoreVersion))) { + NOTICE.addErrorMessage(Messages.PluginWrapper_admonitor_OutdatedCoreVersion(getLongName(), requiredCoreVersion)); throw new IOException(shortName + " requires a more recent core version (" + requiredCoreVersion + ") than the current (" + Jenkins.getVersion() + ")."); } } @@ -725,6 +733,38 @@ public class PluginWrapper implements Comparable, ModelObject { return false; } + @Extension + public final static PluginWrapperAdministrativeMonitor NOTICE = new PluginWrapperAdministrativeMonitor(); + + /** + * Administrative Monitor for failed plugins + */ + public static final class PluginWrapperAdministrativeMonitor extends AdministrativeMonitor { + public final List pluginError = new ArrayList<>(); + + void addErrorMessage(String error) { + pluginError.add(error); + } + + public boolean isActivated() { + return !pluginError.isEmpty(); + } + + /** + * Depending on whether the user said "dismiss" or "correct", send him to the right place. + */ + public void doAct(StaplerRequest req, StaplerResponse rsp) throws IOException { + if(req.hasParameter("correct")) { + rsp.sendRedirect(req.getContextPath()+"/pluginManager"); + + } + } + + public static PluginWrapperAdministrativeMonitor get() { + return AdministrativeMonitor.all().get(PluginWrapperAdministrativeMonitor.class); + } + } + // // // Action methods diff --git a/core/src/main/resources/hudson/Messages.properties b/core/src/main/resources/hudson/Messages.properties index 038ecc0cd630498340f9863a80a22b0c1d984701..8bdde0139c273a771669630fb0e2623044dfbaf7 100644 --- a/core/src/main/resources/hudson/Messages.properties +++ b/core/src/main/resources/hudson/Messages.properties @@ -73,4 +73,8 @@ ProxyConfiguration.Success=Success Functions.NoExceptionDetails=No Exception details +PluginWrapper.admonitor.OutdatedCoreVersion=Plugin {0} requires Jenkins {1} or later +PluginWrapper.admonitor.MissingDependency=Plugin {0} requires the missing plugin {1} +PluginWrapper.admonitor.DisabledDependency=Plugin {0} depends on the disabled {1} +PluginWrapper.admonitor.ObsoleteDependency=Plugin {0} requires {1} {2} or later TcpSlaveAgentListener.PingAgentProtocol.displayName=Ping protocol diff --git a/core/src/main/resources/hudson/PluginWrapper/PluginWrapperAdministrativeMonitor/message.jelly b/core/src/main/resources/hudson/PluginWrapper/PluginWrapperAdministrativeMonitor/message.jelly new file mode 100644 index 0000000000000000000000000000000000000000..91be4632b20699faa8d1d774a7b36043b4839c7d --- /dev/null +++ b/core/src/main/resources/hudson/PluginWrapper/PluginWrapperAdministrativeMonitor/message.jelly @@ -0,0 +1,15 @@ + + +
+
+
+ +
+
+
    + +
  • ${pluginError}
  • +
    +
+
+
\ No newline at end of file