From 3edb9fdcecedb4514e4b0396306cb0f115a0b321 Mon Sep 17 00:00:00 2001 From: kzantow Date: Mon, 14 Mar 2016 15:36:27 -0400 Subject: [PATCH] JENKINS-33296 - plugin dependency issues during install --- .../main/java/hudson/model/UpdateSite.java | 6 ++-- .../security/HudsonPrivateSecurityRealm.java | 32 +++++++++++++------ .../_entryForm.jelly | 4 ++- war/src/main/js/api/plugins.js | 28 ++++++++-------- war/src/main/js/pluginSetupWizardGui.js | 8 ++++- 5 files changed, 48 insertions(+), 30 deletions(-) diff --git a/core/src/main/java/hudson/model/UpdateSite.java b/core/src/main/java/hudson/model/UpdateSite.java index 09c38fb6e7..05a65fc093 100644 --- a/core/src/main/java/hudson/model/UpdateSite.java +++ b/core/src/main/java/hudson/model/UpdateSite.java @@ -634,10 +634,8 @@ public class UpdateSite { this.categories = o.has("labels") ? (String[])o.getJSONArray("labels").toArray(new String[0]) : null; for(Object jo : o.getJSONArray("dependencies")) { JSONObject depObj = (JSONObject) jo; - // Make sure there's a name attribute, that that name isn't maven-plugin - we ignore that one - - // and that the optional value isn't true. - if (get(depObj,"name")!=null - && !get(depObj,"name").equals("maven-plugin")) { + // Make sure there's a name attribute and that the optional value isn't true. + if (get(depObj,"name")!=null) { if (get(depObj, "optional").equals("false")) { dependencies.put(get(depObj, "name"), get(depObj, "version")); } else { diff --git a/core/src/main/java/hudson/security/HudsonPrivateSecurityRealm.java b/core/src/main/java/hudson/security/HudsonPrivateSecurityRealm.java index 2f45492c35..4d6781eca5 100644 --- a/core/src/main/java/hudson/security/HudsonPrivateSecurityRealm.java +++ b/core/src/main/java/hudson/security/HudsonPrivateSecurityRealm.java @@ -358,7 +358,7 @@ public class HudsonPrivateSecurityRealm extends AbstractPasswordBasedSecurityRea if(si.fullname==null || si.fullname.length()==0) si.fullname = si.username; - if(si.email==null || !si.email.contains("@")) + if(isMailerPluginPresent() && (si.email==null || !si.email.contains("@"))) si.errorMessage = Messages.HudsonPrivateSecurityRealm_CreateAccount_InvalidEmailAddress(); if (! User.isIdOrFullnameAllowed(si.username)) { @@ -379,19 +379,31 @@ public class HudsonPrivateSecurityRealm extends AbstractPasswordBasedSecurityRea // register the user User user = createAccount(si.username,si.password1); user.setFullName(si.fullname); - try { - // legacy hack. mail support has moved out to a separate plugin - Class up = Jenkins.getInstance().pluginManager.uberClassLoader.loadClass("hudson.tasks.Mailer$UserProperty"); - Constructor c = up.getDeclaredConstructor(String.class); - user.addProperty((UserProperty)c.newInstance(si.email)); - } catch (RuntimeException e) { - throw e; - } catch (Exception e) { - LOGGER.log(Level.WARNING, "Failed to set the e-mail address",e); + if(isMailerPluginPresent()) { + try { + // legacy hack. mail support has moved out to a separate plugin + Class up = Jenkins.getInstance().pluginManager.uberClassLoader.loadClass("hudson.tasks.Mailer$UserProperty"); + Constructor c = up.getDeclaredConstructor(String.class); + user.addProperty((UserProperty)c.newInstance(si.email)); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new RuntimeException(e); + } } user.save(); return user; } + + public boolean isMailerPluginPresent() { + try { + // mail support has moved to a separate plugin + return null != Jenkins.getInstance().pluginManager.uberClassLoader.loadClass("hudson.tasks.Mailer$UserProperty"); + } catch (ClassNotFoundException e) { + LOGGER.finer("Mailer plugin not present"); + } + return false; + } /** * Creates a new user account by registering a password to the user. diff --git a/core/src/main/resources/hudson/security/HudsonPrivateSecurityRealm/_entryForm.jelly b/core/src/main/resources/hudson/security/HudsonPrivateSecurityRealm/_entryForm.jelly index 346d8c4d53..a4e2f822f2 100644 --- a/core/src/main/resources/hudson/security/HudsonPrivateSecurityRealm/_entryForm.jelly +++ b/core/src/main/resources/hudson/security/HudsonPrivateSecurityRealm/_entryForm.jelly @@ -22,7 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --> - +

${title}

@@ -49,10 +49,12 @@ THE SOFTWARE. ${%Full name}: + ${%E-mail address}: + ${%Enter text as shown}: diff --git a/war/src/main/js/api/plugins.js b/war/src/main/js/api/plugins.js index c64235d867..fb51f2d6b4 100644 --- a/war/src/main/js/api/plugins.js +++ b/war/src/main/js/api/plugins.js @@ -19,7 +19,7 @@ exports.recommendedPlugins = [ "gradle", "ldap", "mailer", - // "matrix-auth", + "matrix-auth", "pam-auth", "pipeline-stage-view", "ssh-slaves", @@ -38,7 +38,7 @@ exports.availablePlugins = [ { "category":"Organization and Administration", "plugins": [ - // { "name": "dashboard-view" }, + { "name": "dashboard-view" }, { "name": "build-monitor-plugin" }, { "name": "cloudbees-folder" }, { "name": "antisamy-markup-formatter" } @@ -49,15 +49,15 @@ exports.availablePlugins = [ "description":"Add general purpose features to your jobs", "plugins": [ { "name": "ansicolor" }, - // { "name": "build-name-setter" }, + { "name": "build-name-setter" }, { "name": "build-timeout" }, { "name": "config-file-provider" }, { "name": "credentials-binding" }, { "name": "rebuild" }, { "name": "ssh-agent" }, - // { "name": "throttle-concurrents" }, - { "name": "timestamper" } - // { "name": "ws-cleanup" } + { "name": "throttle-concurrents" }, + { "name": "timestamper" }, + { "name": "ws-cleanup" } ] }, { @@ -72,12 +72,12 @@ exports.availablePlugins = [ { "category":"Build Analysis and Reporting", "plugins": [ - // { "name": "checkstyle" }, - // { "name": "cobertura" }, + { "name": "checkstyle" }, + { "name": "cobertura" }, { "name": "htmlpublisher" }, { "name": "junit" }, - // { "name": "sonar" }, - // { "name": "warnings" }, + { "name": "sonar" }, + { "name": "warnings" }, { "name": "xunit" } ] }, @@ -88,8 +88,8 @@ exports.availablePlugins = [ { "name": "github-organization-folder" }, { "name": "pipeline-stage-view" }, { "name": "build-pipeline-plugin" }, - // { "name": "conditional-buildstep" }, - // { "name": "jenkins-multijob-plugin" }, + { "name": "conditional-buildstep" }, + { "name": "jenkins-multijob-plugin" }, { "name": "parameterized-trigger" }, { "name": "copyartifact" } ] @@ -122,10 +122,10 @@ exports.availablePlugins = [ { "category":"User Management and Security", "plugins": [ - // { "name": "matrix-auth" }, + { "name": "matrix-auth" }, { "name": "pam-auth" }, { "name": "ldap" }, - // { "name": "role-strategy" }, + { "name": "role-strategy" }, { "name": "active-directory" } ] }, diff --git a/war/src/main/js/pluginSetupWizardGui.js b/war/src/main/js/pluginSetupWizardGui.js index e011bfb4a4..111450ebc0 100644 --- a/war/src/main/js/pluginSetupWizardGui.js +++ b/war/src/main/js/pluginSetupWizardGui.js @@ -599,7 +599,13 @@ var createPluginSetupWizard = function(appendTarget) { $('.plugin-list .selected').addClass('match'); } else { - var matches = findElementsWithText($pl[0], text.toLowerCase(), function(d) { return d.toLowerCase(); }); + var matches = []; + $containers.find('.title,.description').each(function() { + var localMatches = findElementsWithText(this, text.toLowerCase(), function(d) { return d.toLowerCase(); }); + if(localMatches.length > 0) { + matches = matches.concat(localMatches); + } + }); $(matches).parents('.plugin').addClass('match'); if(lastSearch !== text && scroll) { scrollPlugin($pl, matches, text); -- GitLab