From 84a2117772f2b639fe82eff652c349ff8eae999f Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Wed, 20 Jan 2016 22:24:17 -0800 Subject: [PATCH 001/366] [maven-release-plugin] prepare for next development iteration --- cli/pom.xml | 2 +- core/pom.xml | 2 +- plugins/pom.xml | 10 +++++----- pom.xml | 4 ++-- test/pom.xml | 2 +- war/pom.xml | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cli/pom.xml b/cli/pom.xml index 51fcde1aef..e1779b0f88 100644 --- a/cli/pom.xml +++ b/cli/pom.xml @@ -5,7 +5,7 @@ org.jenkins-ci.main pom - 1.642.1 + 1.642.2-SNAPSHOT cli diff --git a/core/pom.xml b/core/pom.xml index d07b8fde49..5913b1d331 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -29,7 +29,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 1.642.1 + 1.642.2-SNAPSHOT jenkins-core diff --git a/plugins/pom.xml b/plugins/pom.xml index ae70e60b03..825f83a485 100644 --- a/plugins/pom.xml +++ b/plugins/pom.xml @@ -12,7 +12,7 @@ org.jenkins-ci.plugins plugin Jenkins plugin POM - 1.642.1 + 1.642.2-SNAPSHOT pom - + diff --git a/core/src/main/resources/hudson/model/ComputerSet/sidepanel.jelly b/core/src/main/resources/hudson/model/ComputerSet/sidepanel.jelly index a0036a1727..2ff7bc59c0 100644 --- a/core/src/main/resources/hudson/model/ComputerSet/sidepanel.jelly +++ b/core/src/main/resources/hudson/model/ComputerSet/sidepanel.jelly @@ -32,9 +32,9 @@ THE SOFTWARE. - + - + diff --git a/core/src/main/resources/hudson/model/Label/sidepanel.jelly b/core/src/main/resources/hudson/model/Label/sidepanel.jelly index 734a5c53dd..7d662a0a45 100644 --- a/core/src/main/resources/hudson/model/Label/sidepanel.jelly +++ b/core/src/main/resources/hudson/model/Label/sidepanel.jelly @@ -34,7 +34,7 @@ THE SOFTWARE. - + diff --git a/core/src/main/resources/hudson/model/UpdateCenter/sidepanel.jelly b/core/src/main/resources/hudson/model/UpdateCenter/sidepanel.jelly index 3880cfa74c..5f9d40194f 100644 --- a/core/src/main/resources/hudson/model/UpdateCenter/sidepanel.jelly +++ b/core/src/main/resources/hudson/model/UpdateCenter/sidepanel.jelly @@ -32,7 +32,7 @@ THE SOFTWARE. - + diff --git a/core/src/main/resources/hudson/model/User/sidepanel.jelly b/core/src/main/resources/hudson/model/User/sidepanel.jelly index 126bdae5d8..46bad7a605 100644 --- a/core/src/main/resources/hudson/model/User/sidepanel.jelly +++ b/core/src/main/resources/hudson/model/User/sidepanel.jelly @@ -34,7 +34,7 @@ THE SOFTWARE. - + diff --git a/core/src/main/resources/hudson/security/HudsonPrivateSecurityRealm/index.jelly b/core/src/main/resources/hudson/security/HudsonPrivateSecurityRealm/index.jelly index d39afff6f9..9b7fe9d0fa 100644 --- a/core/src/main/resources/hudson/security/HudsonPrivateSecurityRealm/index.jelly +++ b/core/src/main/resources/hudson/security/HudsonPrivateSecurityRealm/index.jelly @@ -43,7 +43,7 @@ THE SOFTWARE. ${user.id} ${user} - + diff --git a/core/src/main/resources/hudson/security/HudsonPrivateSecurityRealm/sidepanel.jelly b/core/src/main/resources/hudson/security/HudsonPrivateSecurityRealm/sidepanel.jelly index 49ef418e78..8d864d01e9 100644 --- a/core/src/main/resources/hudson/security/HudsonPrivateSecurityRealm/sidepanel.jelly +++ b/core/src/main/resources/hudson/security/HudsonPrivateSecurityRealm/sidepanel.jelly @@ -28,7 +28,7 @@ THE SOFTWARE. - + diff --git a/core/src/main/resources/lib/hudson/project/configurable.jelly b/core/src/main/resources/lib/hudson/project/configurable.jelly index c58263ce8c..435a804ab6 100644 --- a/core/src/main/resources/lib/hudson/project/configurable.jelly +++ b/core/src/main/resources/lib/hudson/project/configurable.jelly @@ -39,10 +39,10 @@ THE SOFTWARE. - + - + From 91adcb397f0091ceb2e5f70ae9e4d5ff11bff6b7 Mon Sep 17 00:00:00 2001 From: James Nord Date: Wed, 9 Mar 2016 15:13:29 +0000 Subject: [PATCH 014/366] Add a BIG FAT WARNING for security managers. --- .../init/impl/InstallUncaughtExceptionHandler.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/hudson/init/impl/InstallUncaughtExceptionHandler.java b/core/src/main/java/hudson/init/impl/InstallUncaughtExceptionHandler.java index cbec54ba51..2300ff60b9 100644 --- a/core/src/main/java/hudson/init/impl/InstallUncaughtExceptionHandler.java +++ b/core/src/main/java/hudson/init/impl/InstallUncaughtExceptionHandler.java @@ -40,7 +40,18 @@ public class InstallUncaughtExceptionHandler { } } }); - Thread.setDefaultUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler()); + try { + Thread.setDefaultUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler()); + DefaultUncaughtExceptionHandler.LOGGER.log(Level.INFO, "Succesfully installed a global UncaughtExceptionHandler."); + } + catch (SecurityException ex) { + DefaultUncaughtExceptionHandler.LOGGER.log(Level.SEVERE, + "Failed to set the default UncaughtExceptionHandler. " + + "If any threads die due to unhandled coding errors then there will be no logging of this information. " + + "The lack of this diagnostic information will make it harder to track down issues which will reduce the supportability of Jenkins. " + + "It is highly recomended that you consult the documentation that comes with you servlet container on how to allow the " + + "`setDefaultUncaughtExceptionHandler` permission and enable it.", ex); + } } /** An UncaughtExceptionHandler that just logs the exception */ From 277a743870d89ddd3f2a4daa850462b04e18e16c Mon Sep 17 00:00:00 2001 From: Robert Sandell Date: Wed, 9 Mar 2016 18:45:34 +0100 Subject: [PATCH 015/366] First draft of providing categorisation of Item types in Jenkins --- .../main/java/jenkins/model/ItemCategory.java | 54 ++++++++++++ .../jenkins/model/ItemCategoryMapper.java | 85 +++++++++++++++++++ .../jenkins/model/Messages.properties | 3 + 3 files changed, 142 insertions(+) create mode 100644 core/src/main/java/jenkins/model/ItemCategory.java create mode 100644 core/src/main/java/jenkins/model/ItemCategoryMapper.java diff --git a/core/src/main/java/jenkins/model/ItemCategory.java b/core/src/main/java/jenkins/model/ItemCategory.java new file mode 100644 index 0000000000..8795c19878 --- /dev/null +++ b/core/src/main/java/jenkins/model/ItemCategory.java @@ -0,0 +1,54 @@ +package jenkins.model; + +import hudson.Extension; +import hudson.ExtensionPoint; +import hudson.model.ModelObject; + +/** + * A category for {@link hudson.model.Item}s. + */ +public abstract class ItemCategory implements ModelObject, ExtensionPoint { + + /** + * The icon class specification e.g. 'icon-category-folder', 'icon-help' etc. + * The size specification should not be provided as that is determined by the + * context of where the category is displayed. + * + * @return the icon class specification + */ + public abstract String getIconClassName(); + + /** + * The default category, if an item doesn't belong anywhere else, this is where it goes by default. + */ + @Extension + public static final class Default extends ItemCategory { + + @Override + public String getIconClassName() { + return "icon-category-default"; //TODO whatever Gus decides + } + + @Override + public String getDisplayName() { + return Messages.ItemCategory_Default_DisplayName(); + } + } + + /** + * A category suitable for folder and container (not docker) like items. + */ + @Extension + public static final class Folders extends ItemCategory { + + @Override + public String getIconClassName() { + return "icon-category-folders"; //TODO whatever Gus decides + } + + @Override + public String getDisplayName() { + return Messages.ItemCategory_Folders_DisplayName(); + } + } +} diff --git a/core/src/main/java/jenkins/model/ItemCategoryMapper.java b/core/src/main/java/jenkins/model/ItemCategoryMapper.java new file mode 100644 index 0000000000..e90e30c9b5 --- /dev/null +++ b/core/src/main/java/jenkins/model/ItemCategoryMapper.java @@ -0,0 +1,85 @@ +package jenkins.model; + +import hudson.Extension; +import hudson.ExtensionList; +import hudson.ExtensionPoint; +import hudson.model.Item; + +import javax.annotation.CheckForNull; +import javax.annotation.Nonnull; +import java.util.Collection; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * A mapper of {@link ItemCategory}s to {@link hudson.model.Item}s. + * TODO maybe find a better name + */ +public abstract class ItemCategoryMapper implements ExtensionPoint { + + public static final Logger LOGGER = Logger.getLogger(ItemCategoryMapper.class.getName()); + + /** + * Provides the category for the requested item or null if this mapper doesn't have one. + * + * @param item the item to categorise + * + * @return the category or null + */ + @CheckForNull + public abstract ItemCategory getCategoryFor(@Nonnull Item item); + + /** + * Finds the category specified by the first mapper. + * If none can be found {@link jenkins.model.ItemCategory.Default} is returned. + * + * @param item the item to categorise. + * + * @return the category + */ + @Nonnull + public static ItemCategory getCategory(@Nonnull Item item) { + for (ItemCategoryMapper m : all()) { + try { + ItemCategory category = m.getCategoryFor(item); + if (category != null) { + return category; + } + } catch (Exception ignored) { + LOGGER.log(Level.WARNING, ignored.getMessage(), ignored); + } + } + return ExtensionList.lookup(ItemCategory.Default.class).iterator().next(); + } + + public static Collection all() { + return ExtensionList.lookup(ItemCategoryMapper.class); + } + + /** + * Provides some sensible defaults for at least the 2.0 recommended plugins. + * Any plugin that wants to override this list for their own item should extend {@link ItemCategoryMapper} + * with an {@link Extension#ordinal()} higher than {@code -10000}. + */ + @Extension(ordinal = -10000) + public static final class SensibleDefaultMapper extends ItemCategoryMapper { + + @Override + public ItemCategory getCategoryFor(@Nonnull Item item) { + //TODO load from some file provided by Gus or just if then else hardcoding + return null; + } + } + + /** + * Mapper implementation with the lowest ordinal that simply returns {@link jenkins.model.ItemCategory.Default}. + */ + @Extension(ordinal = Integer.MIN_VALUE) + public static final class DefaultMapper extends ItemCategoryMapper { + + @Override + public ItemCategory getCategoryFor(@Nonnull Item item) { + return ExtensionList.lookup(ItemCategory.Default.class).iterator().next(); + } + } +} diff --git a/core/src/main/resources/jenkins/model/Messages.properties b/core/src/main/resources/jenkins/model/Messages.properties index 63ffa92e53..9cc7f442b1 100644 --- a/core/src/main/resources/jenkins/model/Messages.properties +++ b/core/src/main/resources/jenkins/model/Messages.properties @@ -71,3 +71,6 @@ ParameterizedJobMixIn.build_now=Build Now BlockedBecauseOfBuildInProgress.shortDescription=Build #{0} is already in progress{1} BlockedBecauseOfBuildInProgress.ETA=\ (ETA:{0}) BuildDiscarderProperty.displayName=Discard Old Builds + +ItemCategory.Default.DisplayName=Default/Unsorted +ItemCategory.Folders.DisplayName=Folders and Containers From 09a58b138376cb5356f64e55b2efd7d5e291ee3e Mon Sep 17 00:00:00 2001 From: Manuel Recena Date: Fri, 11 Mar 2016 16:22:32 +0100 Subject: [PATCH 016/366] [JENKINS-31162] Initial source code modification about Item categorization --- .../java/hudson/model/ItemGroupMixIn.java | 34 ++++++++ core/src/main/java/hudson/model/View.java | 12 ++- .../model/ItemCategory/Categories.java | 37 ++++++++ .../jenkins/model/ItemCategory/Category.java | 59 +++++++++++++ .../{ => ItemCategory}/ItemCategory.java | 49 ++++++----- .../ItemCategoryConfigurator.java | 64 ++++++++++++++ .../jenkins/model/ItemCategoryMapper.java | 85 ------------------- .../jenkins/model/Messages.properties | 2 +- 8 files changed, 234 insertions(+), 108 deletions(-) create mode 100644 core/src/main/java/jenkins/model/ItemCategory/Categories.java create mode 100644 core/src/main/java/jenkins/model/ItemCategory/Category.java rename core/src/main/java/jenkins/model/{ => ItemCategory}/ItemCategory.java (54%) create mode 100644 core/src/main/java/jenkins/model/ItemCategory/ItemCategoryConfigurator.java delete mode 100644 core/src/main/java/jenkins/model/ItemCategoryMapper.java diff --git a/core/src/main/java/hudson/model/ItemGroupMixIn.java b/core/src/main/java/hudson/model/ItemGroupMixIn.java index 15c1283743..1c4c89b34d 100644 --- a/core/src/main/java/hudson/model/ItemGroupMixIn.java +++ b/core/src/main/java/hudson/model/ItemGroupMixIn.java @@ -29,8 +29,13 @@ import hudson.model.listeners.ItemListener; import hudson.security.AccessControlled; import hudson.util.CopyOnWriteMap; import hudson.util.Function1; +import jenkins.model.ItemCategory.Categories; +import jenkins.model.ItemCategory.Category; +import jenkins.model.ItemCategory.ItemCategory; +import jenkins.model.ItemCategory.ItemCategoryConfigurator; import jenkins.model.Jenkins; import jenkins.util.xml.XMLUtils; +import org.acegisecurity.Authentication; import org.kohsuke.stapler.StaplerRequest; import org.kohsuke.stapler.StaplerResponse; @@ -44,6 +49,8 @@ import java.io.File; import java.io.FileFilter; import java.io.IOException; import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; @@ -328,6 +335,33 @@ public abstract class ItemGroupMixIn { return item; } + /** + * Populate a {$link Categories} from a specific {$link ItemGroup}. + * + * @return + */ + public static Categories getCategories(Authentication a, ItemGroup c) { + Categories categories = new Categories(); + for (TopLevelItemDescriptor descriptor : Items.all(a, c)) { + ItemCategory ic = ItemCategoryConfigurator.getCategory(descriptor); + int i = 0; + boolean found = false; + while (i < categories.getItems().size() && !found) { + if (categories.getItems().get(i).getId() == ic.getId()) { + categories.getItems().get(i).getItems().add(descriptor.clazz.getName()); + found = true; + } + i++; + } + if (!found) { + List descriptors = new ArrayList(); + descriptors.add(descriptor.clazz.getName()); + categories.getItems().add(new Category(ic.getId(), ic.getDisplayName(), ic.getDescription(), ic.getIconClassName(), descriptors)); + } + } + return categories; + } + /** * Pointless wrapper to avoid HotSpot problem. See JENKINS-5756 */ diff --git a/core/src/main/java/hudson/model/View.java b/core/src/main/java/hudson/model/View.java index 0cfa562922..193a349bd0 100644 --- a/core/src/main/java/hudson/model/View.java +++ b/core/src/main/java/hudson/model/View.java @@ -54,6 +54,7 @@ import hudson.util.RunList; import hudson.util.XStream2; import hudson.views.ListViewColumn; import hudson.widgets.Widget; +import jenkins.model.ItemCategory.Categories; import jenkins.model.Jenkins; import jenkins.model.ModelObjectWithChildren; import jenkins.util.ProgressiveRendering; @@ -917,7 +918,7 @@ public abstract class View extends AbstractModelObject implements AccessControll SearchIndexBuilder sib = super.makeSearchIndex(); sib.add(new CollectionSearchIndex() {// for jobs in the view protected TopLevelItem get(String key) { return getItem(key); } - protected Collection all() { return getItems(); } + protected Collection all() { return getItems(); } @Override protected String getName(TopLevelItem o) { // return the name instead of the display for suggestion searching @@ -1000,6 +1001,15 @@ public abstract class View extends AbstractModelObject implements AccessControll */ public abstract Item doCreateItem( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException; + /** + * A new API method to get the allowed {$link TopLevelItem}s and its categories. + * + * @return A {$Categories} entity that is shown as JSON file. + */ + public Categories doCategories(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { + return ItemGroupMixIn.getCategories(Jenkins.getAuthentication(), Jenkins.getInstance()); + } + public void doRssAll( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException { rss(req, rsp, " all builds", getBuilds()); } diff --git a/core/src/main/java/jenkins/model/ItemCategory/Categories.java b/core/src/main/java/jenkins/model/ItemCategory/Categories.java new file mode 100644 index 0000000000..e05400f901 --- /dev/null +++ b/core/src/main/java/jenkins/model/ItemCategory/Categories.java @@ -0,0 +1,37 @@ +package jenkins.model.ItemCategory; + +import org.kohsuke.stapler.HttpResponse; +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.export.Flavor; + +import javax.servlet.ServletException; +import java.io.IOException; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +/** + * It is a logic representation of a set of {$Category}. + */ +@ExportedBean +public class Categories implements HttpResponse, Serializable { + + private List items; + + public Categories() { + items = new ArrayList(); + } + + @Exported(name = "categories") + public List getItems() { + return items; + } + + @Override + public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node) throws IOException, ServletException { + rsp.serveExposedBean(req, this, Flavor.JSON); + } +} diff --git a/core/src/main/java/jenkins/model/ItemCategory/Category.java b/core/src/main/java/jenkins/model/ItemCategory/Category.java new file mode 100644 index 0000000000..dd4eaff7e0 --- /dev/null +++ b/core/src/main/java/jenkins/model/ItemCategory/Category.java @@ -0,0 +1,59 @@ +package jenkins.model.ItemCategory; + +import hudson.model.TopLevelItem; +import org.kohsuke.stapler.export.Exported; +import org.kohsuke.stapler.export.ExportedBean; + +import java.io.Serializable; +import java.util.List; + +/** + * Represents an {$link ItemCategory} and its {@link TopLevelItem}s. + */ +@ExportedBean +public class Category implements Serializable { + + private String id; + + private String name; + + private String description; + + private String iconClassName; + + private List items; + + public Category(String id, String name, String description, String iconClassName, List items) { + this.id= id; + this.name = name; + this.description = description; + this.iconClassName = iconClassName; + this.items = items; + } + + @Exported + public String getId() { + return id; + } + + @Exported + public String getName() { + return name; + } + + @Exported + public String getDescription() { + return description; + } + + @Exported + public String getIconClassName() { + return iconClassName; + } + + @Exported + public List getItems() { + return items; + } + +} diff --git a/core/src/main/java/jenkins/model/ItemCategory.java b/core/src/main/java/jenkins/model/ItemCategory/ItemCategory.java similarity index 54% rename from core/src/main/java/jenkins/model/ItemCategory.java rename to core/src/main/java/jenkins/model/ItemCategory/ItemCategory.java index 8795c19878..32115136aa 100644 --- a/core/src/main/java/jenkins/model/ItemCategory.java +++ b/core/src/main/java/jenkins/model/ItemCategory/ItemCategory.java @@ -1,8 +1,9 @@ -package jenkins.model; +package jenkins.model.ItemCategory; import hudson.Extension; import hudson.ExtensionPoint; import hudson.model.ModelObject; +import jenkins.model.Messages; /** * A category for {@link hudson.model.Item}s. @@ -10,23 +11,45 @@ import hudson.model.ModelObject; public abstract class ItemCategory implements ModelObject, ExtensionPoint { /** - * The icon class specification e.g. 'icon-category-folder', 'icon-help' etc. - * The size specification should not be provided as that is determined by the - * context of where the category is displayed. + * Identifier, e.g. "category-id-default", etc. + * + * @return the identifier + */ + public abstract String getId(); + + /** + * The icon class specification e.g. 'category-icon-folder', 'category-icon-default', etc. * * @return the icon class specification */ public abstract String getIconClassName(); + /** + * The description in plain text + * + * @return the description + */ + public abstract String getDescription(); + /** * The default category, if an item doesn't belong anywhere else, this is where it goes by default. */ @Extension public static final class Default extends ItemCategory { + @Override + public String getId() { + return "category-id-default"; + } + @Override public String getIconClassName() { - return "icon-category-default"; //TODO whatever Gus decides + return "category-icon-default"; + } + + @Override + public String getDescription() { + return Messages.ItemCategory_Default_Description(); } @Override @@ -35,20 +58,4 @@ public abstract class ItemCategory implements ModelObject, ExtensionPoint { } } - /** - * A category suitable for folder and container (not docker) like items. - */ - @Extension - public static final class Folders extends ItemCategory { - - @Override - public String getIconClassName() { - return "icon-category-folders"; //TODO whatever Gus decides - } - - @Override - public String getDisplayName() { - return Messages.ItemCategory_Folders_DisplayName(); - } - } } diff --git a/core/src/main/java/jenkins/model/ItemCategory/ItemCategoryConfigurator.java b/core/src/main/java/jenkins/model/ItemCategory/ItemCategoryConfigurator.java new file mode 100644 index 0000000000..4f0a882c0e --- /dev/null +++ b/core/src/main/java/jenkins/model/ItemCategory/ItemCategoryConfigurator.java @@ -0,0 +1,64 @@ +package jenkins.model.ItemCategory; + +import hudson.Extension; +import hudson.ExtensionList; +import hudson.ExtensionPoint; +import hudson.model.TopLevelItemDescriptor; + +import javax.annotation.CheckForNull; +import javax.annotation.Nonnull; +import java.util.Collection; +import java.util.logging.Logger; + +/** + * A mapper of {@link ItemCategory}s to {@link hudson.model.Item}s. + */ +public abstract class ItemCategoryConfigurator implements ExtensionPoint { + + public static final Logger LOGGER = Logger.getLogger(ItemCategoryConfigurator.class.getName()); + + /** + * Provides the category for the requested item or null if this mapper doesn't have one. + * + * @param descriptor the item to categorise + * + * @return the category or null + */ + @CheckForNull + protected abstract ItemCategory getCategoryFor(@Nonnull TopLevelItemDescriptor descriptor); + + /** + * Finds the category specified by the first mapper. + * If none can be found {@link ItemCategory.Default} is returned. + * + * @param descriptor the item to categorise. + * + * @return the category + */ + @Nonnull + public static ItemCategory getCategory(@Nonnull TopLevelItemDescriptor descriptor) { + for (ItemCategoryConfigurator m : all()) { + ItemCategory category = m.getCategoryFor(descriptor); + if (category != null) { + return category; + } + } + throw new IllegalStateException(); + } + + public static Collection all() { + return ExtensionList.lookup(ItemCategoryConfigurator.class); + } + + /** + * Mapper implementation with the lowest ordinal that simply returns {@link ItemCategory.Default}. + */ + @Extension(ordinal = Integer.MIN_VALUE) + public static final class DefaultConfigurator extends ItemCategoryConfigurator { + + @Override + public ItemCategory getCategoryFor(@Nonnull TopLevelItemDescriptor descriptor) { + return ExtensionList.lookup(ItemCategory.Default.class).iterator().next(); + } + } +} diff --git a/core/src/main/java/jenkins/model/ItemCategoryMapper.java b/core/src/main/java/jenkins/model/ItemCategoryMapper.java deleted file mode 100644 index e90e30c9b5..0000000000 --- a/core/src/main/java/jenkins/model/ItemCategoryMapper.java +++ /dev/null @@ -1,85 +0,0 @@ -package jenkins.model; - -import hudson.Extension; -import hudson.ExtensionList; -import hudson.ExtensionPoint; -import hudson.model.Item; - -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; -import java.util.Collection; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * A mapper of {@link ItemCategory}s to {@link hudson.model.Item}s. - * TODO maybe find a better name - */ -public abstract class ItemCategoryMapper implements ExtensionPoint { - - public static final Logger LOGGER = Logger.getLogger(ItemCategoryMapper.class.getName()); - - /** - * Provides the category for the requested item or null if this mapper doesn't have one. - * - * @param item the item to categorise - * - * @return the category or null - */ - @CheckForNull - public abstract ItemCategory getCategoryFor(@Nonnull Item item); - - /** - * Finds the category specified by the first mapper. - * If none can be found {@link jenkins.model.ItemCategory.Default} is returned. - * - * @param item the item to categorise. - * - * @return the category - */ - @Nonnull - public static ItemCategory getCategory(@Nonnull Item item) { - for (ItemCategoryMapper m : all()) { - try { - ItemCategory category = m.getCategoryFor(item); - if (category != null) { - return category; - } - } catch (Exception ignored) { - LOGGER.log(Level.WARNING, ignored.getMessage(), ignored); - } - } - return ExtensionList.lookup(ItemCategory.Default.class).iterator().next(); - } - - public static Collection all() { - return ExtensionList.lookup(ItemCategoryMapper.class); - } - - /** - * Provides some sensible defaults for at least the 2.0 recommended plugins. - * Any plugin that wants to override this list for their own item should extend {@link ItemCategoryMapper} - * with an {@link Extension#ordinal()} higher than {@code -10000}. - */ - @Extension(ordinal = -10000) - public static final class SensibleDefaultMapper extends ItemCategoryMapper { - - @Override - public ItemCategory getCategoryFor(@Nonnull Item item) { - //TODO load from some file provided by Gus or just if then else hardcoding - return null; - } - } - - /** - * Mapper implementation with the lowest ordinal that simply returns {@link jenkins.model.ItemCategory.Default}. - */ - @Extension(ordinal = Integer.MIN_VALUE) - public static final class DefaultMapper extends ItemCategoryMapper { - - @Override - public ItemCategory getCategoryFor(@Nonnull Item item) { - return ExtensionList.lookup(ItemCategory.Default.class).iterator().next(); - } - } -} diff --git a/core/src/main/resources/jenkins/model/Messages.properties b/core/src/main/resources/jenkins/model/Messages.properties index 9cc7f442b1..677d8d1f2a 100644 --- a/core/src/main/resources/jenkins/model/Messages.properties +++ b/core/src/main/resources/jenkins/model/Messages.properties @@ -73,4 +73,4 @@ BlockedBecauseOfBuildInProgress.ETA=\ (ETA:{0}) BuildDiscarderProperty.displayName=Discard Old Builds ItemCategory.Default.DisplayName=Default/Unsorted -ItemCategory.Folders.DisplayName=Folders and Containers +ItemCategory.Default.Description=Description From 83f4a19f0b09ea7403a1b86d6312d12d1708230e Mon Sep 17 00:00:00 2001 From: James Nord Date: Fri, 11 Mar 2016 17:40:21 +0000 Subject: [PATCH 017/366] fixt typo fix typos spotted by @jglick's eagle eyes --- .../java/hudson/init/impl/InstallUncaughtExceptionHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/hudson/init/impl/InstallUncaughtExceptionHandler.java b/core/src/main/java/hudson/init/impl/InstallUncaughtExceptionHandler.java index 2300ff60b9..d8b42da8b6 100644 --- a/core/src/main/java/hudson/init/impl/InstallUncaughtExceptionHandler.java +++ b/core/src/main/java/hudson/init/impl/InstallUncaughtExceptionHandler.java @@ -64,7 +64,7 @@ public class InstallUncaughtExceptionHandler { // if this was an OutOfMemoryError then all bets about logging are off - but in the absence of anything else... LOGGER.log(Level.SEVERE, "A thread (" + t.getName() + '/' + t.getId() - + ") died unexepectedly due to an uncaught exception, this may leave your Jenkins in a bad way and is usually indicitive of a bug in the code.", + + ") died unexpectedly due to an uncaught exception, this may leave your Jenkins in a bad way and is usually indicative of a bug in the code.", ex); } From f3b92f8a4db733c2d78f50a89fcb5f02d49637c9 Mon Sep 17 00:00:00 2001 From: Manuel Recena Date: Fri, 11 Mar 2016 19:59:58 +0100 Subject: [PATCH 018/366] [JENKINS-31162] New fields were added to the JSON file --- .../main/java/hudson/model/ItemGroupMixIn.java | 16 ++++++++++++---- .../jenkins/model/ItemCategory/Category.java | 15 ++++++++++++--- .../jenkins/model/ItemCategory/ItemCategory.java | 13 +++++++++++++ 3 files changed, 37 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/hudson/model/ItemGroupMixIn.java b/core/src/main/java/hudson/model/ItemGroupMixIn.java index 1c4c89b34d..70c02479b1 100644 --- a/core/src/main/java/hudson/model/ItemGroupMixIn.java +++ b/core/src/main/java/hudson/model/ItemGroupMixIn.java @@ -50,6 +50,7 @@ import java.io.FileFilter; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.logging.Level; @@ -348,15 +349,22 @@ public abstract class ItemGroupMixIn { boolean found = false; while (i < categories.getItems().size() && !found) { if (categories.getItems().get(i).getId() == ic.getId()) { - categories.getItems().get(i).getItems().add(descriptor.clazz.getName()); + Map metadata = new HashMap(); + metadata.put("class", descriptor.clazz.getName()); + metadata.put("iconClassName", "item-icon-" + descriptor.clazz.getName().substring(descriptor.clazz.getName().lastIndexOf(".") + 1).toLowerCase()); + categories.getItems().get(i).getItems().add(metadata); found = true; } i++; } if (!found) { - List descriptors = new ArrayList(); - descriptors.add(descriptor.clazz.getName()); - categories.getItems().add(new Category(ic.getId(), ic.getDisplayName(), ic.getDescription(), ic.getIconClassName(), descriptors)); + Map metadata = new HashMap(); + metadata.put("class", descriptor.clazz.getName()); + metadata.put("iconClassName", "item-icon-" + descriptor.clazz.getName().substring(descriptor.clazz.getName().lastIndexOf(".") + 1).toLowerCase()); + List> temp = new ArrayList>(); + temp.add(metadata); + categories.getItems().add(new Category(ic.getId(), ic.getDisplayName(), ic.getDescription(), + ic.getIconClassName(), ic.getWeight(), temp)); } } return categories; diff --git a/core/src/main/java/jenkins/model/ItemCategory/Category.java b/core/src/main/java/jenkins/model/ItemCategory/Category.java index dd4eaff7e0..8dbff451a3 100644 --- a/core/src/main/java/jenkins/model/ItemCategory/Category.java +++ b/core/src/main/java/jenkins/model/ItemCategory/Category.java @@ -6,6 +6,7 @@ import org.kohsuke.stapler.export.ExportedBean; import java.io.Serializable; import java.util.List; +import java.util.Map; /** * Represents an {$link ItemCategory} and its {@link TopLevelItem}s. @@ -21,13 +22,16 @@ public class Category implements Serializable { private String iconClassName; - private List items; + private int weight; - public Category(String id, String name, String description, String iconClassName, List items) { + private List> items; + + public Category(String id, String name, String description, String iconClassName, int weight, List> items) { this.id= id; this.name = name; this.description = description; this.iconClassName = iconClassName; + this.weight = weight; this.items = items; } @@ -52,7 +56,12 @@ public class Category implements Serializable { } @Exported - public List getItems() { + public int getWeight() { + return weight; + } + + @Exported + public List> getItems() { return items; } diff --git a/core/src/main/java/jenkins/model/ItemCategory/ItemCategory.java b/core/src/main/java/jenkins/model/ItemCategory/ItemCategory.java index 32115136aa..287e1467b6 100644 --- a/core/src/main/java/jenkins/model/ItemCategory/ItemCategory.java +++ b/core/src/main/java/jenkins/model/ItemCategory/ItemCategory.java @@ -31,6 +31,13 @@ public abstract class ItemCategory implements ModelObject, ExtensionPoint { */ public abstract String getDescription(); + /** + * Helpful to set the order. + * + * @return the weight + */ + public abstract int getWeight(); + /** * The default category, if an item doesn't belong anywhere else, this is where it goes by default. */ @@ -56,6 +63,12 @@ public abstract class ItemCategory implements ModelObject, ExtensionPoint { public String getDisplayName() { return Messages.ItemCategory_Default_DisplayName(); } + + @Override + public int getWeight() { + return Integer.MIN_VALUE; + } + } } From e140be8544313f870040d38714865cd93ac0a5d0 Mon Sep 17 00:00:00 2001 From: Manuel Recena Date: Fri, 11 Mar 2016 21:21:26 +0100 Subject: [PATCH 019/366] [JENKINS-31162] New fields were added to the JSON file --- .../java/hudson/model/ItemGroupMixIn.java | 8 ++-- .../jenkins/model/ItemCategory/Category.java | 6 +-- .../ItemCategoryConfigurator.java | 45 ++++++++++++++++--- 3 files changed, 48 insertions(+), 11 deletions(-) diff --git a/core/src/main/java/hudson/model/ItemGroupMixIn.java b/core/src/main/java/hudson/model/ItemGroupMixIn.java index 70c02479b1..36923dfc4e 100644 --- a/core/src/main/java/hudson/model/ItemGroupMixIn.java +++ b/core/src/main/java/hudson/model/ItemGroupMixIn.java @@ -349,19 +349,21 @@ public abstract class ItemGroupMixIn { boolean found = false; while (i < categories.getItems().size() && !found) { if (categories.getItems().get(i).getId() == ic.getId()) { - Map metadata = new HashMap(); + Map metadata = new HashMap(); metadata.put("class", descriptor.clazz.getName()); metadata.put("iconClassName", "item-icon-" + descriptor.clazz.getName().substring(descriptor.clazz.getName().lastIndexOf(".") + 1).toLowerCase()); + metadata.put("weight", ItemCategoryConfigurator.getWeight(descriptor)); categories.getItems().get(i).getItems().add(metadata); found = true; } i++; } if (!found) { - Map metadata = new HashMap(); + Map metadata = new HashMap(); metadata.put("class", descriptor.clazz.getName()); metadata.put("iconClassName", "item-icon-" + descriptor.clazz.getName().substring(descriptor.clazz.getName().lastIndexOf(".") + 1).toLowerCase()); - List> temp = new ArrayList>(); + metadata.put("weight", ItemCategoryConfigurator.getWeight(descriptor)); + List> temp = new ArrayList>(); temp.add(metadata); categories.getItems().add(new Category(ic.getId(), ic.getDisplayName(), ic.getDescription(), ic.getIconClassName(), ic.getWeight(), temp)); diff --git a/core/src/main/java/jenkins/model/ItemCategory/Category.java b/core/src/main/java/jenkins/model/ItemCategory/Category.java index 8dbff451a3..52738b00ae 100644 --- a/core/src/main/java/jenkins/model/ItemCategory/Category.java +++ b/core/src/main/java/jenkins/model/ItemCategory/Category.java @@ -24,9 +24,9 @@ public class Category implements Serializable { private int weight; - private List> items; + private List> items; - public Category(String id, String name, String description, String iconClassName, int weight, List> items) { + public Category(String id, String name, String description, String iconClassName, int weight, List> items) { this.id= id; this.name = name; this.description = description; @@ -61,7 +61,7 @@ public class Category implements Serializable { } @Exported - public List> getItems() { + public List> getItems() { return items; } diff --git a/core/src/main/java/jenkins/model/ItemCategory/ItemCategoryConfigurator.java b/core/src/main/java/jenkins/model/ItemCategory/ItemCategoryConfigurator.java index 4f0a882c0e..bdd2c43d18 100644 --- a/core/src/main/java/jenkins/model/ItemCategory/ItemCategoryConfigurator.java +++ b/core/src/main/java/jenkins/model/ItemCategory/ItemCategoryConfigurator.java @@ -15,12 +15,10 @@ import java.util.logging.Logger; */ public abstract class ItemCategoryConfigurator implements ExtensionPoint { - public static final Logger LOGGER = Logger.getLogger(ItemCategoryConfigurator.class.getName()); - /** * Provides the category for the requested item or null if this mapper doesn't have one. * - * @param descriptor the item to categorise + * @param descriptor the item to categorize * * @return the category or null */ @@ -28,10 +26,10 @@ public abstract class ItemCategoryConfigurator implements ExtensionPoint { protected abstract ItemCategory getCategoryFor(@Nonnull TopLevelItemDescriptor descriptor); /** - * Finds the category specified by the first mapper. + * Finds the category specified by the first configurator. * If none can be found {@link ItemCategory.Default} is returned. * - * @param descriptor the item to categorise. + * @param descriptor the item to categorize. * * @return the category */ @@ -46,6 +44,35 @@ public abstract class ItemCategoryConfigurator implements ExtensionPoint { throw new IllegalStateException(); } + /** + * Provides the weight for the requested item. Helpful to order a list. + * + * @param descriptor the item to categorize + * + * @return the weight or null + */ + @CheckForNull + protected abstract Integer getWeightFor(@Nonnull TopLevelItemDescriptor descriptor); + + /** + * Finds the category specified by the first mapper. + * If none can be found {@link ItemCategory.Default} is returned. + * + * @param descriptor the item to categorize. + * + * @return the category + */ + @Nonnull + public static Integer getWeight(@Nonnull TopLevelItemDescriptor descriptor) { + for (ItemCategoryConfigurator m : all()) { + Integer weight = m.getWeightFor(descriptor); + if (weight != null) { + return weight; + } + } + throw new IllegalStateException(); + } + public static Collection all() { return ExtensionList.lookup(ItemCategoryConfigurator.class); } @@ -56,9 +83,17 @@ public abstract class ItemCategoryConfigurator implements ExtensionPoint { @Extension(ordinal = Integer.MIN_VALUE) public static final class DefaultConfigurator extends ItemCategoryConfigurator { + @Nonnull @Override public ItemCategory getCategoryFor(@Nonnull TopLevelItemDescriptor descriptor) { return ExtensionList.lookup(ItemCategory.Default.class).iterator().next(); } + + @Nonnull + @Override + public Integer getWeightFor(@Nonnull TopLevelItemDescriptor descriptor) { + return Integer.MIN_VALUE; + } + } } From ef5b11b7c8738689f014afbd1085bc8f71906ae7 Mon Sep 17 00:00:00 2001 From: Manuel Recena Date: Fri, 11 Mar 2016 22:35:31 +0100 Subject: [PATCH 020/366] [JENKINS-31162] @tfennelly's comment was addresed --- core/src/main/java/hudson/model/ItemGroupMixIn.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/hudson/model/ItemGroupMixIn.java b/core/src/main/java/hudson/model/ItemGroupMixIn.java index 36923dfc4e..408c50caef 100644 --- a/core/src/main/java/hudson/model/ItemGroupMixIn.java +++ b/core/src/main/java/hudson/model/ItemGroupMixIn.java @@ -348,7 +348,7 @@ public abstract class ItemGroupMixIn { int i = 0; boolean found = false; while (i < categories.getItems().size() && !found) { - if (categories.getItems().get(i).getId() == ic.getId()) { + if (categories.getItems().get(i).getId().equals(ic.getId())) { Map metadata = new HashMap(); metadata.put("class", descriptor.clazz.getName()); metadata.put("iconClassName", "item-icon-" + descriptor.clazz.getName().substring(descriptor.clazz.getName().lastIndexOf(".") + 1).toLowerCase()); From 85365c6f399cd3dcdc9a0c10fb6737e4d9a3e5ca Mon Sep 17 00:00:00 2001 From: Allan Burdajewicz Date: Sat, 12 Mar 2016 14:27:42 +1000 Subject: [PATCH 021/366] [JENKINS-32525] - Added warning. --- core/src/main/java/hudson/tasks/BuildTrigger.java | 2 +- core/src/main/resources/hudson/tasks/Messages.properties | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/hudson/tasks/BuildTrigger.java b/core/src/main/java/hudson/tasks/BuildTrigger.java index 5737b2e9f6..1783f09215 100644 --- a/core/src/main/java/hudson/tasks/BuildTrigger.java +++ b/core/src/main/java/hudson/tasks/BuildTrigger.java @@ -368,7 +368,7 @@ public class BuildTrigger extends Recorder implements DependencyDeclarer { */ public FormValidation doCheck(@AncestorInPath AbstractProject project, @QueryParameter String value) { // JENKINS-32525: Check that it behaves gracefully for an unknown context - if (project == null) return FormValidation.ok(); + if (project == null) return FormValidation.ok(Messages.BuildTrigger_ok_ancestor_is_null()); // Require CONFIGURE permission on this project if(!project.hasPermission(Item.CONFIGURE)) return FormValidation.ok(); diff --git a/core/src/main/resources/hudson/tasks/Messages.properties b/core/src/main/resources/hudson/tasks/Messages.properties index f7ceb03840..1cc86c71d7 100644 --- a/core/src/main/resources/hudson/tasks/Messages.properties +++ b/core/src/main/resources/hudson/tasks/Messages.properties @@ -47,6 +47,7 @@ BuildTrigger.NoSuchProject=No such project \u2018{0}\u2019. Did you mean \u2018{ BuildTrigger.NoProjectSpecified=No project specified BuildTrigger.NotBuildable={0} is not buildable BuildTrigger.Triggering=Triggering a new build of {0} +BuildTrigger.ok_ancestor_is_null=Ancestor/Context Unknown: the project specified cannot be validated BuildTrigger.warning_access_control_for_builds_in_glo=Warning: \u2018Access Control for Builds\u2019 in global security configuration is empty, so falling back to legacy behavior of permitting any downstream builds to be triggered BuildTrigger.warning_this_build_has_no_associated_aut=Warning: this build has no associated authentication, so build permissions may be lacking, and downstream projects which cannot even be seen by an anonymous user will be silently skipped BuildTrigger.warning_you_have_no_plugins_providing_ac=Warning: you have no plugins providing access control for builds, so falling back to legacy behavior of permitting any downstream builds to be triggered From ab42dbeab30e946ee74ba47925cc78ae2dac898f Mon Sep 17 00:00:00 2001 From: Christopher Orr Date: Wed, 9 Mar 2016 02:58:54 +0100 Subject: [PATCH 022/366] Update documentation for the Agent configuration page. --- .../hudson/model/Messages.properties | 4 +- .../hudson/model/Node/help-labelString.html | 30 +++++++--- .../hudson/model/Node/help-name.html | 11 ++-- .../hudson/model/Node/help-numExecutors.html | 19 +++--- .../hudson/model/Slave/help-remoteFS.html | 38 ++++++------ .../slaves/CommandLauncher/help.properties | 2 +- .../config.jelly | 6 +- .../slaves/JNLPLauncher/help.properties | 14 +++-- .../hudson/slaves/Messages.properties | 10 ++-- .../config.jelly | 2 +- .../master-slave/availability.html | 60 +++++++++++-------- .../master-slave/demand/idleDelay.html | 5 +- .../master-slave/demand/inDemandDelay.html | 6 +- .../master-slave/demand/keepUpWhenActive.html | 5 ++ .../master-slave/description.html | 13 ++-- .../system-config/master-slave/usage.html | 25 ++++---- .../nodeEnvironmentVariables.html | 30 +++++++++- 17 files changed, 168 insertions(+), 112 deletions(-) create mode 100644 war/src/main/webapp/help/system-config/master-slave/demand/keepUpWhenActive.html diff --git a/core/src/main/resources/hudson/model/Messages.properties b/core/src/main/resources/hudson/model/Messages.properties index c952af5760..95f3a11bf2 100644 --- a/core/src/main/resources/hudson/model/Messages.properties +++ b/core/src/main/resources/hudson/model/Messages.properties @@ -333,8 +333,8 @@ Node.BecauseNodeIsReserved={0} is reserved for jobs with matching label expressi Node.BecauseNodeIsNotAcceptingTasks={0} is not accepting tasks Node.LabelMissing={0} doesn\u2019t have label {1} Node.LackingBuildPermission={0} doesn\u2019t have a permission to run on {1} -Node.Mode.NORMAL=Utilize this node as much as possible -Node.Mode.EXCLUSIVE=Only build jobs with label restrictions matching this node +Node.Mode.NORMAL=Use this node as much as possible +Node.Mode.EXCLUSIVE=Only build jobs with label expressions matching this node ListView.DisplayName=List View diff --git a/core/src/main/resources/hudson/model/Node/help-labelString.html b/core/src/main/resources/hudson/model/Node/help-labelString.html index b0b96bc81d..a7cfc252c1 100644 --- a/core/src/main/resources/hudson/model/Node/help-labelString.html +++ b/core/src/main/resources/hudson/model/Node/help-labelString.html @@ -1,11 +1,23 @@
- Labels (AKA tags) are used for grouping multiple agents into one logical group. - Use spaces between each label. For instance 'regression java6' will assign a - node the labels 'regression' and 'java6'. - + Labels (or tags) are used to group multiple agents into one logical group.

- For example, if you have multiple Windows agents and you have jobs that require - Windows, then you can configure all your Windows agents to have the label 'windows', - then tie the job to the 'windows' label. This allows your job to run on any - of your Windows agents but not on anywhere else. -

\ No newline at end of file + For example, if you have multiple Windows agents and you have a job that + must run on Windows, then you could configure all your Windows agents to have + the label windows, and then tie that job to this label. +
+ This would ensure that your job runs on one of your Windows agents, but not on + any agents without this label. +

+ Labels do not necessarily have to represent the operating system on the agent; + you can also use labels to note the CPU architecture, or that a certain tool + is installed on the agent. +

+ Multiple labels must be separated by a space. For example, + windows docker would assign two labels to the agent: windows + and docker. +

+ Labels may contain any non-space characters, but you should avoid special + characters such as any of these: !&|<>(), as other Jenkins + features allow for defining label expressions, where these characters may be + used. + diff --git a/core/src/main/resources/hudson/model/Node/help-name.html b/core/src/main/resources/hudson/model/Node/help-name.html index dd9c242a06..aa412606d4 100644 --- a/core/src/main/resources/hudson/model/Node/help-name.html +++ b/core/src/main/resources/hudson/model/Node/help-name.html @@ -1,7 +1,10 @@

- Name that uniquely identifies a agent within this Jenkins installation. - + Name that uniquely identifies an agent within this Jenkins installation.

- This value could be any string, and doesn't have to be the same as the agent host name, - but it's often convenient to make them the same. + This does not have to be the same as the agent hostname (where applicable), + but it is often convenient to make them the same. +

+ The name may not contain any characters from this list: + ?*/\%!@#$^&|<>[]:; +

diff --git a/core/src/main/resources/hudson/model/Node/help-numExecutors.html b/core/src/main/resources/hudson/model/Node/help-numExecutors.html index 4d362213ba..c45d3505a5 100644 --- a/core/src/main/resources/hudson/model/Node/help-numExecutors.html +++ b/core/src/main/resources/hudson/model/Node/help-numExecutors.html @@ -1,15 +1,12 @@
- This controls the number of concurrent builds that Jenkins can perform. So the value - affects the overall system load Jenkins may incur. - A good value to start with would be the number of processors on your system. - + This controls the number of concurrent builds that Jenkins may perform on the + master agent. So the value affects the overall system load Jenkins may incur. + A good value to start with would be the number of CPU cores on the machine.

- Increasing this value beyond that would cause each build to take longer, but it could increase - the overall throughput, because it allows CPU to build one project while another build is waiting - for I/O. - + Increasing this value beyond that would cause each build to take longer, but + it could increase the overall throughput. For example, one build may be + CPU-bound, and in the meantime another build, which is I/O-bound, can take + advantage of the spare I/O capacity at that moment.

- When using Jenkins in the master/agent mode, setting this value to 0 would prevent the master - from doing any building on its own. Agents may not have zero executors, but may be - temporarily disabled using the button on the agent's status page. + Setting this value to 0 will prevent the master from executing any builds.

diff --git a/core/src/main/resources/hudson/model/Slave/help-remoteFS.html b/core/src/main/resources/hudson/model/Slave/help-remoteFS.html index d40a982a9b..6915c41fb3 100644 --- a/core/src/main/resources/hudson/model/Slave/help-remoteFS.html +++ b/core/src/main/resources/hudson/model/Slave/help-remoteFS.html @@ -1,36 +1,34 @@

An agent needs to have a directory dedicated to Jenkins. Specify - the path of this work directory on the agent. It is best to use - an absolute path, such as '/var/jenkins' or 'c:\jenkins'. This - should be a path local to the agent machine. There's no need for - this path to be visible from the master, under normal circumstances. - + the path to this directory on the agent. It is best to use + an absolute path, such as /var/jenkins or c:\jenkins. + This should be a path local to the agent machine. There is no need for + this path to be visible from the master.

- Agents do not maintain important data (other than active workspaces - of projects last built on it), so you can possibly set the agent - workspace to a temporary directory. The only downside of doing this - is that you may lose the up-to-date workspace if the agent is turned off. - + Agents do not maintain important data; all job configurations, build logs and + artifacts are stored on the master, so it would be possible to use a temporary + directory as the agent root directory. +
+ However, by giving an agent a directory that is not deleted after a machine + reboot, for example, the agent can cache data such as tool installations, or + build workspaces. This prevents unnecessary downloading of tools, or checking + out source code again when builds start to run on this agent again after a + reboot.

- If you use a relative path, such as './jenkins-slave', the path will - be relative to the current working directory that the launcher provides. + If you use a relative path, such as ./jenkins-agent, the path will be + relative to the working directory provided by the Launch method.

  • For launchers where Jenkins controls starting the agent process, such as SSH, the current working directory will typically be consistent, - e.g. the user's home directory. This means that Jenkins will be able to - rely on the caching of tool installations and workspaces from previous - builds. -
  • + e.g. the user's home directory.
  • For launchers where Jenkins has no control over starting the agent process, such as JNLP when launched from either the command line or via a web browser link, the current working directory may change between launches of the agent and use of a relative path may prove problematic. +
    The principal issue encountered when using relative paths with launchers like JNLP is the proliferation of stale workspaces and tool installation - on the agent machine. This can cause disk space issues. - Note: there are some cloud providers that specifically use relative - paths with the JNLP launcher to allow for dynamically provisioned pools - of semi-heterogeneous agents.
  • + on the agent machine. This can cause disk space issues.
diff --git a/core/src/main/resources/hudson/slaves/CommandLauncher/help.properties b/core/src/main/resources/hudson/slaves/CommandLauncher/help.properties index a980d82ce8..ea17495f1d 100644 --- a/core/src/main/resources/hudson/slaves/CommandLauncher/help.properties +++ b/core/src/main/resources/hudson/slaves/CommandLauncher/help.properties @@ -21,4 +21,4 @@ # THE SOFTWARE. blurb=Starts an agent by having Jenkins execute a command from the master. \ - Use this when the master is capable of remotely executing a process on an agent, such as through ssh/rsh. + Use this when the master is capable of remotely executing a process on another machine, e.g. via SSH or RSH. diff --git a/core/src/main/resources/hudson/slaves/EnvironmentVariablesNodeProperty/config.jelly b/core/src/main/resources/hudson/slaves/EnvironmentVariablesNodeProperty/config.jelly index 9cd7fbc2e6..b2becef5dc 100644 --- a/core/src/main/resources/hudson/slaves/EnvironmentVariablesNodeProperty/config.jelly +++ b/core/src/main/resources/hudson/slaves/EnvironmentVariablesNodeProperty/config.jelly @@ -24,13 +24,13 @@ THE SOFTWARE. - + - + - + diff --git a/core/src/main/resources/hudson/slaves/JNLPLauncher/help.properties b/core/src/main/resources/hudson/slaves/JNLPLauncher/help.properties index 393be7ebba..ead4ac4209 100644 --- a/core/src/main/resources/hudson/slaves/JNLPLauncher/help.properties +++ b/core/src/main/resources/hudson/slaves/JNLPLauncher/help.properties @@ -20,7 +20,13 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -blurb=Starts an agent by launching a program through JNLP. \ - The launch in this case is initiated by the agent itself, \ - thus agents need not be IP reachable from the master (e.g. behind the firewall.) \ - It is still possible to start a launch without GUI, for example as a Windows service. \ No newline at end of file +blurb=Allows an agent to be launched using Java Web Start.
\ + In this case, a JNLP file must be opened on the agent machine, which will \ + establish a TCP connection to the Jenkins master.
\ + This means that the agent need not be reachable from the master; the agent \ + just needs to be able to reach the master. If you have \ + enabled security, you \ + can customise which port the Jenkins master will listen on for incoming JNLP \ + agent connections.
\ + By default, the JNLP agent will launch a GUI, but it's also possible to run \ + a JNLP agent without a GUI, e.g. as a Window service. diff --git a/core/src/main/resources/hudson/slaves/Messages.properties b/core/src/main/resources/hudson/slaves/Messages.properties index cefa0fcdeb..c3a247c284 100644 --- a/core/src/main/resources/hudson/slaves/Messages.properties +++ b/core/src/main/resources/hudson/slaves/Messages.properties @@ -20,11 +20,11 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -RetentionStrategy.Always.displayName=Keep this agent on-line as much as possible -RetentionStrategy.Demand.displayName=Take this agent on-line when in demand and off-line when idle +RetentionStrategy.Always.displayName=Keep this agent online as much as possible +RetentionStrategy.Demand.displayName=Take this agent online when in demand, and offline when idle RetentionStrategy.Demand.OfflineIdle=Offline because computer was idle; it will be relaunched when needed. -CommandLauncher.displayName=Launch agent via execution of command on the Master -JNLPLauncher.displayName=Launch agents via Java Web Start +CommandLauncher.displayName=Launch agent via execution of command on the master +JNLPLauncher.displayName=Launch agent via Java Web Start ComputerLauncher.unexpectedError=Unexpected error in launching an agent. This is probably a bug in Jenkins ComputerLauncher.abortedLaunch=Launching agent process aborted. CommandLauncher.NoLaunchCommand=No launch command specified @@ -34,7 +34,7 @@ NodeProvisioner.EmptyString= OfflineCause.LaunchFailed=This agent is offline because Jenkins failed to launch the agent process on it. OfflineCause.connection_was_broken_=Connection was broken: {0} SimpleScheduledRetentionStrategy.FinishedUpTime=Computer has finished its scheduled uptime -SimpleScheduledRetentionStrategy.displayName=Take this agent on-line according to a schedule +SimpleScheduledRetentionStrategy.displayName=Take this agent online according to a schedule EnvironmentVariablesNodeProperty.displayName=Environment variables SlaveComputer.DisconnectedBy=Disconnected by {0}{1} NodeDescripter.CheckName.Mandatory=Name is mandatory diff --git a/core/src/main/resources/hudson/slaves/SimpleScheduledRetentionStrategy/config.jelly b/core/src/main/resources/hudson/slaves/SimpleScheduledRetentionStrategy/config.jelly index e06ed7537b..3ef03e52aa 100644 --- a/core/src/main/resources/hudson/slaves/SimpleScheduledRetentionStrategy/config.jelly +++ b/core/src/main/resources/hudson/slaves/SimpleScheduledRetentionStrategy/config.jelly @@ -35,7 +35,7 @@ THE SOFTWARE. name="retentionStrategy.upTimeMins" value="${instance.upTimeMins}" checkMessage="${%Scheduled Uptime is mandatory and must be a number.}"/>
- + diff --git a/war/src/main/webapp/help/system-config/master-slave/availability.html b/war/src/main/webapp/help/system-config/master-slave/availability.html index 9048fd30e5..987ca69f27 100644 --- a/war/src/main/webapp/help/system-config/master-slave/availability.html +++ b/war/src/main/webapp/help/system-config/master-slave/availability.html @@ -1,46 +1,56 @@
- Controls when Jenkins starts and stops the slave. + Controls when Jenkins starts and stops this agent.
- Keep this slave on-line as much as possible + Keep this agent online as much as possible
- This is the default and normal setting. - In this mode, Jenkins uses tries to keep the slave on-line. - If Jenkins can start the slave without user assistance, it will periodically - attempt to restart the slave if it is unavailable. - Jenkins will not take the slave off-line. + In this mode, Jenkins will keep this agent online as much as + possible. +

+ If the agent goes offline, e.g. due to a temporary network failure, + Jenkins will periodically attempt to restart it.

- + In this mode, Jenkins will bring this agent online at the scheduled + time(s), remaining online for a specified amount of time. +

+ If the agent goes offline while it is scheduled to be online, + Jenkins will periodically attempt to restart it. +

+ After this agent has been online for the number of minutes specified + in the Scheduled Uptime field, it will be taken offline. +
+ If Keep online while builds are running is checked, and the + agent is scheduled to be taken offline, Jenkins will wait for any + any builds that may be in progress to complete. +

- Take this slave on-line when in demand and off-line when idle + Take this agent online when in demand, and offline when idle
- In this mode, if Jenkins can launch the slave without user assistance, it will periodically - attempt to launch the slave while there are unexecuted jobs which meet the following criteria: + In this mode, Jenkins will bring this agent online if there + is demand, i.e. there are queued builds which meet the following + criteria:
    -
  • They have been in the queue for at least the specified startup demand period
  • -
  • They can execute on this slave
  • +
  • They have been in the queue for at least the specified In + demand delay time period
  • +
  • They can be executed by this agent (e.g. have a matching + label expression)
- The slave will be taken off-line if: + This agent will be taken offline if:
    -
  • There are no active jobs running on the slave
  • -
  • The slave has been idle for at least the specified idle period
  • +
  • There are no active builds running on this agent
  • +
  • This agent has been idle for at least the specified Idle + delay time period
-
\ No newline at end of file + diff --git a/war/src/main/webapp/help/system-config/master-slave/demand/idleDelay.html b/war/src/main/webapp/help/system-config/master-slave/demand/idleDelay.html index 77c1070f81..9ab94f6f92 100644 --- a/war/src/main/webapp/help/system-config/master-slave/demand/idleDelay.html +++ b/war/src/main/webapp/help/system-config/master-slave/demand/idleDelay.html @@ -1,3 +1,4 @@
- The number of minutes that this slave must remain idle before taking it off-line. -
\ No newline at end of file + The number of minutes that this agent must remain idle before Jenkins will + take it offline. + diff --git a/war/src/main/webapp/help/system-config/master-slave/demand/inDemandDelay.html b/war/src/main/webapp/help/system-config/master-slave/demand/inDemandDelay.html index a019c22412..050a49f784 100644 --- a/war/src/main/webapp/help/system-config/master-slave/demand/inDemandDelay.html +++ b/war/src/main/webapp/help/system-config/master-slave/demand/inDemandDelay.html @@ -1,4 +1,4 @@
- The number of minutes for which jobs must be waiting in the queue before - attempting to launch this slave. -
\ No newline at end of file + The number of minutes for which jobs must have been waiting in the queue + before Jenkins will attempt to bring this agent online. + diff --git a/war/src/main/webapp/help/system-config/master-slave/demand/keepUpWhenActive.html b/war/src/main/webapp/help/system-config/master-slave/demand/keepUpWhenActive.html new file mode 100644 index 0000000000..fedb5a8a98 --- /dev/null +++ b/war/src/main/webapp/help/system-config/master-slave/demand/keepUpWhenActive.html @@ -0,0 +1,5 @@ +
+ If checked, and this agent is scheduled to be taken offline, but there are + builds in progress, Jenkins will wait for those builds to complete before + taking this agent offline. +
diff --git a/war/src/main/webapp/help/system-config/master-slave/description.html b/war/src/main/webapp/help/system-config/master-slave/description.html index ea5b85eef6..f83a2b4395 100644 --- a/war/src/main/webapp/help/system-config/master-slave/description.html +++ b/war/src/main/webapp/help/system-config/master-slave/description.html @@ -1,11 +1,6 @@
- Optional human-readable description of this slave. This information - is displayed on the project configuration screen. - + Optional human-readable description for this agent.

- When you have slaves that are different from others, it's often helpful - to use this field to explain what is different. For example, entering - "Windows slave" in this field would allow project owners to choose to - always build on a Windows machine (for example, if they need some - Windows-specific build tool.) -

\ No newline at end of file + This could include information useful to users, such as how many CPU cores the + agent has, how much RAM it has installed, its physical location, etc. + diff --git a/war/src/main/webapp/help/system-config/master-slave/usage.html b/war/src/main/webapp/help/system-config/master-slave/usage.html index 6180ec7b56..7a82e29015 100644 --- a/war/src/main/webapp/help/system-config/master-slave/usage.html +++ b/war/src/main/webapp/help/system-config/master-slave/usage.html @@ -3,27 +3,32 @@
- Utilize this node as much as possible + Use this node as much as possible
- This is the default and normal setting. + This is the default setting. +
In this mode, Jenkins uses this node freely. Whenever there is a build that can be done by using this node, Jenkins will use it.
- Only build jobs with label restrictions matching this node + Only build jobs with label expressions matching this node
In this mode, Jenkins will only build a project on this node when that project is restricted to certain nodes using a label expression, and that expression matches this node's name and/or labels. - - This allows a slave to be reserved for certain kinds of jobs. - For example, to run performance tests continuously from Jenkins, - you can use this setting with # of executors as 1, so that only one performance - test runs at any given time, and that one executor won't be blocked - by other builds that can be done on other nodes. +

+ This allows a node to be reserved for certain kinds of jobs. + For example, if you have jobs that run performance tests, you may want + them to only run on a specially configured machine, while preventing all + other jobs from using that machine. To do so, you would restrict where the + test jobs may run by giving them a label expression matching that machine. +
+ Furthermore, if you set the # of executors value to 1, you + can ensure that only one performance test will execute at any given time + on that machine; no other builds will interfere.

- \ No newline at end of file + diff --git a/war/src/main/webapp/help/system-config/nodeEnvironmentVariables.html b/war/src/main/webapp/help/system-config/nodeEnvironmentVariables.html index cc7cddfa38..0246a2453c 100644 --- a/war/src/main/webapp/help/system-config/nodeEnvironmentVariables.html +++ b/war/src/main/webapp/help/system-config/nodeEnvironmentVariables.html @@ -1,4 +1,28 @@
- These key-value pairs apply for every build on this node and override any global values. They can be used in Jenkins' - configuration (as $key or ${key}) and be will added to the environment for processes launched from the build. -
\ No newline at end of file + Environment variables defined here will be made available to every build + executed by this agent, and will override any environment variables that have + the same Name as those defined on the + Configure System page. +

+ Using the syntax $NAME or ${NAME} + (%NAME% on Windows), these variables can be used in job + configurations, or from process launched by a build. +

+ Jenkins also supports a special syntax, BASE+EXTRA, which allows + you to add multiple key-value pairs here, which will be prepended to an + existing environment variable. +

+ For example, if you have a machine which has PATH=/usr/bin, you + could add to the standard path by defining an environment variable here, with + the name PATH+LOCAL_BIN and value /usr/local/bin. +
+ This would result in PATH=/usr/local/bin:/usr/bin being exported + during builds executed on this machine. + PATH+LOCAL_BIN=/usr/local/bin will also be exported. +
+ Multiple entries are prepended to the "base" variable according to the + alphabetical order of the "extra" part of the name. +

+ If the Value is empty or whitespace-only, it will not be added to the + environment. + From 259cebec84f1e0d2f9c7754e9bdad44fbd4481c4 Mon Sep 17 00:00:00 2001 From: Manuel Recena Date: Sun, 13 Mar 2016 14:05:59 +0100 Subject: [PATCH 023/366] [JENKINS-31162] @abayer's comment was addressed --- core/src/main/java/hudson/model/ItemGroupMixIn.java | 8 ++++---- core/src/main/java/hudson/model/View.java | 2 +- .../model/{ItemCategory => item_category}/Categories.java | 2 +- .../model/{ItemCategory => item_category}/Category.java | 4 ++-- .../{ItemCategory => item_category}/ItemCategory.java | 2 +- .../ItemCategoryConfigurator.java | 3 +-- 6 files changed, 10 insertions(+), 11 deletions(-) rename core/src/main/java/jenkins/model/{ItemCategory => item_category}/Categories.java (96%) rename core/src/main/java/jenkins/model/{ItemCategory => item_category}/Category.java (92%) rename core/src/main/java/jenkins/model/{ItemCategory => item_category}/ItemCategory.java (97%) rename core/src/main/java/jenkins/model/{ItemCategory => item_category}/ItemCategoryConfigurator.java (97%) diff --git a/core/src/main/java/hudson/model/ItemGroupMixIn.java b/core/src/main/java/hudson/model/ItemGroupMixIn.java index 408c50caef..0536b0549f 100644 --- a/core/src/main/java/hudson/model/ItemGroupMixIn.java +++ b/core/src/main/java/hudson/model/ItemGroupMixIn.java @@ -29,10 +29,10 @@ import hudson.model.listeners.ItemListener; import hudson.security.AccessControlled; import hudson.util.CopyOnWriteMap; import hudson.util.Function1; -import jenkins.model.ItemCategory.Categories; -import jenkins.model.ItemCategory.Category; -import jenkins.model.ItemCategory.ItemCategory; -import jenkins.model.ItemCategory.ItemCategoryConfigurator; +import jenkins.model.item_category.Categories; +import jenkins.model.item_category.Category; +import jenkins.model.item_category.ItemCategory; +import jenkins.model.item_category.ItemCategoryConfigurator; import jenkins.model.Jenkins; import jenkins.util.xml.XMLUtils; import org.acegisecurity.Authentication; diff --git a/core/src/main/java/hudson/model/View.java b/core/src/main/java/hudson/model/View.java index 193a349bd0..a6c3aacad3 100644 --- a/core/src/main/java/hudson/model/View.java +++ b/core/src/main/java/hudson/model/View.java @@ -54,7 +54,7 @@ import hudson.util.RunList; import hudson.util.XStream2; import hudson.views.ListViewColumn; import hudson.widgets.Widget; -import jenkins.model.ItemCategory.Categories; +import jenkins.model.item_category.Categories; import jenkins.model.Jenkins; import jenkins.model.ModelObjectWithChildren; import jenkins.util.ProgressiveRendering; diff --git a/core/src/main/java/jenkins/model/ItemCategory/Categories.java b/core/src/main/java/jenkins/model/item_category/Categories.java similarity index 96% rename from core/src/main/java/jenkins/model/ItemCategory/Categories.java rename to core/src/main/java/jenkins/model/item_category/Categories.java index e05400f901..c757f34870 100644 --- a/core/src/main/java/jenkins/model/ItemCategory/Categories.java +++ b/core/src/main/java/jenkins/model/item_category/Categories.java @@ -1,4 +1,4 @@ -package jenkins.model.ItemCategory; +package jenkins.model.item_category; import org.kohsuke.stapler.HttpResponse; import org.kohsuke.stapler.StaplerRequest; diff --git a/core/src/main/java/jenkins/model/ItemCategory/Category.java b/core/src/main/java/jenkins/model/item_category/Category.java similarity index 92% rename from core/src/main/java/jenkins/model/ItemCategory/Category.java rename to core/src/main/java/jenkins/model/item_category/Category.java index 52738b00ae..6490d3f9b1 100644 --- a/core/src/main/java/jenkins/model/ItemCategory/Category.java +++ b/core/src/main/java/jenkins/model/item_category/Category.java @@ -1,4 +1,4 @@ -package jenkins.model.ItemCategory; +package jenkins.model.item_category; import hudson.model.TopLevelItem; import org.kohsuke.stapler.export.Exported; @@ -9,7 +9,7 @@ import java.util.List; import java.util.Map; /** - * Represents an {$link ItemCategory} and its {@link TopLevelItem}s. + * Represents an {$link item_category} and its {@link TopLevelItem}s. */ @ExportedBean public class Category implements Serializable { diff --git a/core/src/main/java/jenkins/model/ItemCategory/ItemCategory.java b/core/src/main/java/jenkins/model/item_category/ItemCategory.java similarity index 97% rename from core/src/main/java/jenkins/model/ItemCategory/ItemCategory.java rename to core/src/main/java/jenkins/model/item_category/ItemCategory.java index 287e1467b6..cf16dafba1 100644 --- a/core/src/main/java/jenkins/model/ItemCategory/ItemCategory.java +++ b/core/src/main/java/jenkins/model/item_category/ItemCategory.java @@ -1,4 +1,4 @@ -package jenkins.model.ItemCategory; +package jenkins.model.item_category; import hudson.Extension; import hudson.ExtensionPoint; diff --git a/core/src/main/java/jenkins/model/ItemCategory/ItemCategoryConfigurator.java b/core/src/main/java/jenkins/model/item_category/ItemCategoryConfigurator.java similarity index 97% rename from core/src/main/java/jenkins/model/ItemCategory/ItemCategoryConfigurator.java rename to core/src/main/java/jenkins/model/item_category/ItemCategoryConfigurator.java index bdd2c43d18..429c850878 100644 --- a/core/src/main/java/jenkins/model/ItemCategory/ItemCategoryConfigurator.java +++ b/core/src/main/java/jenkins/model/item_category/ItemCategoryConfigurator.java @@ -1,4 +1,4 @@ -package jenkins.model.ItemCategory; +package jenkins.model.item_category; import hudson.Extension; import hudson.ExtensionList; @@ -8,7 +8,6 @@ import hudson.model.TopLevelItemDescriptor; import javax.annotation.CheckForNull; import javax.annotation.Nonnull; import java.util.Collection; -import java.util.logging.Logger; /** * A mapper of {@link ItemCategory}s to {@link hudson.model.Item}s. From e0946ee9b1ed9e72c86a6c08a13d37e889ff15fb Mon Sep 17 00:00:00 2001 From: Manuel Recena Date: Sun, 13 Mar 2016 17:18:04 +0100 Subject: [PATCH 024/366] [JENKINS-31162] Another @tfennelly's comment was addresed --- .../java/hudson/model/ItemGroupMixIn.java | 33 ++++++++----------- .../model/item_category/Categories.java | 13 ++++++++ 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/core/src/main/java/hudson/model/ItemGroupMixIn.java b/core/src/main/java/hudson/model/ItemGroupMixIn.java index 0536b0549f..b1d0aab962 100644 --- a/core/src/main/java/hudson/model/ItemGroupMixIn.java +++ b/core/src/main/java/hudson/model/ItemGroupMixIn.java @@ -345,28 +345,21 @@ public abstract class ItemGroupMixIn { Categories categories = new Categories(); for (TopLevelItemDescriptor descriptor : Items.all(a, c)) { ItemCategory ic = ItemCategoryConfigurator.getCategory(descriptor); - int i = 0; - boolean found = false; - while (i < categories.getItems().size() && !found) { - if (categories.getItems().get(i).getId().equals(ic.getId())) { - Map metadata = new HashMap(); - metadata.put("class", descriptor.clazz.getName()); - metadata.put("iconClassName", "item-icon-" + descriptor.clazz.getName().substring(descriptor.clazz.getName().lastIndexOf(".") + 1).toLowerCase()); - metadata.put("weight", ItemCategoryConfigurator.getWeight(descriptor)); - categories.getItems().get(i).getItems().add(metadata); - found = true; - } - i++; - } - if (!found) { - Map metadata = new HashMap(); - metadata.put("class", descriptor.clazz.getName()); - metadata.put("iconClassName", "item-icon-" + descriptor.clazz.getName().substring(descriptor.clazz.getName().lastIndexOf(".") + 1).toLowerCase()); - metadata.put("weight", ItemCategoryConfigurator.getWeight(descriptor)); + Map metadata = new HashMap(); + + metadata.put("class", descriptor.clazz.getName()); + metadata.put("iconClassName", "item-icon-" + descriptor.clazz.getName().substring(descriptor.clazz.getName().lastIndexOf(".") + 1).toLowerCase()); + metadata.put("weight", ItemCategoryConfigurator.getWeight(descriptor)); + + Category category = categories.getItem(ic.getId()); + if (category != null) { + category.getItems().add(metadata); + } else { List> temp = new ArrayList>(); temp.add(metadata); - categories.getItems().add(new Category(ic.getId(), ic.getDisplayName(), ic.getDescription(), - ic.getIconClassName(), ic.getWeight(), temp)); + category = new Category(ic.getId(), ic.getDisplayName(), ic.getDescription(), ic.getIconClassName(), + ic.getWeight(), temp); + categories.getItems().add(category); } } return categories; diff --git a/core/src/main/java/jenkins/model/item_category/Categories.java b/core/src/main/java/jenkins/model/item_category/Categories.java index c757f34870..05f6e14a42 100644 --- a/core/src/main/java/jenkins/model/item_category/Categories.java +++ b/core/src/main/java/jenkins/model/item_category/Categories.java @@ -7,6 +7,8 @@ import org.kohsuke.stapler.export.Exported; import org.kohsuke.stapler.export.ExportedBean; import org.kohsuke.stapler.export.Flavor; +import javax.annotation.CheckForNull; +import javax.annotation.Nonnull; import javax.servlet.ServletException; import java.io.IOException; import java.io.Serializable; @@ -34,4 +36,15 @@ public class Categories implements HttpResponse, Serializable { public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node) throws IOException, ServletException { rsp.serveExposedBean(req, this, Flavor.JSON); } + + @CheckForNull + public Category getItem(@Nonnull String id) { + for (Category category : items) { + if (category.getId().equals(id)) { + return category; + } + } + return null; + } + } From 25f9c99d8376667b2efaabe8cb6f5b4be6024618 Mon Sep 17 00:00:00 2001 From: Manuel Recena Date: Sun, 13 Mar 2016 18:09:10 +0100 Subject: [PATCH 025/366] [JENKINS-31162] @gusreiber's comments were addresed --- .../main/java/hudson/model/ItemGroupMixIn.java | 3 ++- .../jenkins/model/item_category/Category.java | 11 ++++++++++- .../model/item_category/ItemCategory.java | 16 ++++++++++++++++ .../item_category/ItemCategoryConfigurator.java | 4 ++-- 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/hudson/model/ItemGroupMixIn.java b/core/src/main/java/hudson/model/ItemGroupMixIn.java index b1d0aab962..b5866bd428 100644 --- a/core/src/main/java/hudson/model/ItemGroupMixIn.java +++ b/core/src/main/java/hudson/model/ItemGroupMixIn.java @@ -350,6 +350,7 @@ public abstract class ItemGroupMixIn { metadata.put("class", descriptor.clazz.getName()); metadata.put("iconClassName", "item-icon-" + descriptor.clazz.getName().substring(descriptor.clazz.getName().lastIndexOf(".") + 1).toLowerCase()); metadata.put("weight", ItemCategoryConfigurator.getWeight(descriptor)); + metadata.put("name", descriptor.getDisplayName()); Category category = categories.getItem(ic.getId()); if (category != null) { @@ -358,7 +359,7 @@ public abstract class ItemGroupMixIn { List> temp = new ArrayList>(); temp.add(metadata); category = new Category(ic.getId(), ic.getDisplayName(), ic.getDescription(), ic.getIconClassName(), - ic.getWeight(), temp); + ic.getWeight(), ic.getMinToShow(), temp); categories.getItems().add(category); } } diff --git a/core/src/main/java/jenkins/model/item_category/Category.java b/core/src/main/java/jenkins/model/item_category/Category.java index 6490d3f9b1..c447751cb6 100644 --- a/core/src/main/java/jenkins/model/item_category/Category.java +++ b/core/src/main/java/jenkins/model/item_category/Category.java @@ -24,14 +24,18 @@ public class Category implements Serializable { private int weight; + private int minToShow; + private List> items; - public Category(String id, String name, String description, String iconClassName, int weight, List> items) { + public Category(String id, String name, String description, String iconClassName, int weight, int minToShow, + List> items) { this.id= id; this.name = name; this.description = description; this.iconClassName = iconClassName; this.weight = weight; + this.minToShow = minToShow; this.items = items; } @@ -60,6 +64,11 @@ public class Category implements Serializable { return weight; } + @Exported + public int getMinToShow() { + return minToShow; + } + @Exported public List> getItems() { return items; diff --git a/core/src/main/java/jenkins/model/item_category/ItemCategory.java b/core/src/main/java/jenkins/model/item_category/ItemCategory.java index cf16dafba1..f4a67aaae2 100644 --- a/core/src/main/java/jenkins/model/item_category/ItemCategory.java +++ b/core/src/main/java/jenkins/model/item_category/ItemCategory.java @@ -10,6 +10,10 @@ import jenkins.model.Messages; */ public abstract class ItemCategory implements ModelObject, ExtensionPoint { + public static int MIN_WEIGHT = Integer.MIN_VALUE; + + public static int MIN_TOSHOW = 1; + /** * Identifier, e.g. "category-id-default", etc. * @@ -38,6 +42,13 @@ public abstract class ItemCategory implements ModelObject, ExtensionPoint { */ public abstract int getWeight(); + /** + * Minimum number required to show the category. + * + * @return the minimum items required + */ + public abstract int getMinToShow(); + /** * The default category, if an item doesn't belong anywhere else, this is where it goes by default. */ @@ -69,6 +80,11 @@ public abstract class ItemCategory implements ModelObject, ExtensionPoint { return Integer.MIN_VALUE; } + @Override + public int getMinToShow() { + return 1; + } + } } diff --git a/core/src/main/java/jenkins/model/item_category/ItemCategoryConfigurator.java b/core/src/main/java/jenkins/model/item_category/ItemCategoryConfigurator.java index 429c850878..cf5d3b3338 100644 --- a/core/src/main/java/jenkins/model/item_category/ItemCategoryConfigurator.java +++ b/core/src/main/java/jenkins/model/item_category/ItemCategoryConfigurator.java @@ -40,7 +40,7 @@ public abstract class ItemCategoryConfigurator implements ExtensionPoint { return category; } } - throw new IllegalStateException(); + throw new IllegalStateException("At least, must exist the category: " + ItemCategory.Default.class); } /** @@ -69,7 +69,7 @@ public abstract class ItemCategoryConfigurator implements ExtensionPoint { return weight; } } - throw new IllegalStateException(); + throw new IllegalStateException("At least, must exist the category: " + ItemCategory.Default.class); } public static Collection all() { From 4ce10855c760d4435c31537ebb31fd92e5ad6175 Mon Sep 17 00:00:00 2001 From: Manuel Recena Date: Sun, 13 Mar 2016 18:26:23 +0100 Subject: [PATCH 026/366] [JENKINS-31162] @oleg-nenashev's comments were addressed --- core/src/main/java/hudson/model/ItemGroupMixIn.java | 9 +++++---- .../main/java/jenkins/model/item_category/Category.java | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/hudson/model/ItemGroupMixIn.java b/core/src/main/java/hudson/model/ItemGroupMixIn.java index b5866bd428..417b9dac19 100644 --- a/core/src/main/java/hudson/model/ItemGroupMixIn.java +++ b/core/src/main/java/hudson/model/ItemGroupMixIn.java @@ -49,6 +49,7 @@ import java.io.File; import java.io.FileFilter; import java.io.IOException; import java.io.InputStream; +import java.io.Serializable; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -337,15 +338,15 @@ public abstract class ItemGroupMixIn { } /** - * Populate a {$link Categories} from a specific {$link ItemGroup}. + * Populate a {@link Categories} object from a specific {@link ItemGroup}. * - * @return + * @return A object that represents a set of {@link Category} */ public static Categories getCategories(Authentication a, ItemGroup c) { Categories categories = new Categories(); for (TopLevelItemDescriptor descriptor : Items.all(a, c)) { ItemCategory ic = ItemCategoryConfigurator.getCategory(descriptor); - Map metadata = new HashMap(); + Map metadata = new HashMap(); metadata.put("class", descriptor.clazz.getName()); metadata.put("iconClassName", "item-icon-" + descriptor.clazz.getName().substring(descriptor.clazz.getName().lastIndexOf(".") + 1).toLowerCase()); @@ -356,7 +357,7 @@ public abstract class ItemGroupMixIn { if (category != null) { category.getItems().add(metadata); } else { - List> temp = new ArrayList>(); + List> temp = new ArrayList>(); temp.add(metadata); category = new Category(ic.getId(), ic.getDisplayName(), ic.getDescription(), ic.getIconClassName(), ic.getWeight(), ic.getMinToShow(), temp); diff --git a/core/src/main/java/jenkins/model/item_category/Category.java b/core/src/main/java/jenkins/model/item_category/Category.java index c447751cb6..34506bdebf 100644 --- a/core/src/main/java/jenkins/model/item_category/Category.java +++ b/core/src/main/java/jenkins/model/item_category/Category.java @@ -26,10 +26,10 @@ public class Category implements Serializable { private int minToShow; - private List> items; + private List> items; public Category(String id, String name, String description, String iconClassName, int weight, int minToShow, - List> items) { + List> items) { this.id= id; this.name = name; this.description = description; @@ -70,7 +70,7 @@ public class Category implements Serializable { } @Exported - public List> getItems() { + public List> getItems() { return items; } From ac7288857b20669ef8df1a119a4cb12aa00a20b3 Mon Sep 17 00:00:00 2001 From: recena Date: Mon, 14 Mar 2016 12:36:14 +0100 Subject: [PATCH 027/366] [JENKINS-31162] Some javadoc were reviewed --- core/src/main/java/hudson/model/View.java | 6 ++++-- .../main/java/jenkins/model/item_category/Categories.java | 4 +++- .../src/main/java/jenkins/model/item_category/Category.java | 4 +++- .../main/java/jenkins/model/item_category/ItemCategory.java | 4 +++- .../model/item_category/ItemCategoryConfigurator.java | 6 ++++-- 5 files changed, 17 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/hudson/model/View.java b/core/src/main/java/hudson/model/View.java index a6c3aacad3..31bd89c94d 100644 --- a/core/src/main/java/hudson/model/View.java +++ b/core/src/main/java/hudson/model/View.java @@ -1002,9 +1002,11 @@ public abstract class View extends AbstractModelObject implements AccessControll public abstract Item doCreateItem( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException; /** - * A new API method to get the allowed {$link TopLevelItem}s and its categories. + * An API method to get the allowed {$link TopLevelItem}s and its categories. * - * @return A {$Categories} entity that is shown as JSON file. + * @return A {@link Categories} entity that is shown as JSON file. + * + * @since TODO */ public Categories doCategories(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { return ItemGroupMixIn.getCategories(Jenkins.getAuthentication(), Jenkins.getInstance()); diff --git a/core/src/main/java/jenkins/model/item_category/Categories.java b/core/src/main/java/jenkins/model/item_category/Categories.java index 05f6e14a42..f11226e9bc 100644 --- a/core/src/main/java/jenkins/model/item_category/Categories.java +++ b/core/src/main/java/jenkins/model/item_category/Categories.java @@ -16,7 +16,9 @@ import java.util.ArrayList; import java.util.List; /** - * It is a logic representation of a set of {$Category}. + * It is a logic representation of a set of {@link Category}. + * + * This class is not thread-safe. */ @ExportedBean public class Categories implements HttpResponse, Serializable { diff --git a/core/src/main/java/jenkins/model/item_category/Category.java b/core/src/main/java/jenkins/model/item_category/Category.java index 34506bdebf..c48bf257f1 100644 --- a/core/src/main/java/jenkins/model/item_category/Category.java +++ b/core/src/main/java/jenkins/model/item_category/Category.java @@ -9,7 +9,9 @@ import java.util.List; import java.util.Map; /** - * Represents an {$link item_category} and its {@link TopLevelItem}s. + * Represents an {@link ItemCategory} and its {@link TopLevelItem}s. + * + * This class is not thread-safe. */ @ExportedBean public class Category implements Serializable { diff --git a/core/src/main/java/jenkins/model/item_category/ItemCategory.java b/core/src/main/java/jenkins/model/item_category/ItemCategory.java index f4a67aaae2..4bd8396169 100644 --- a/core/src/main/java/jenkins/model/item_category/ItemCategory.java +++ b/core/src/main/java/jenkins/model/item_category/ItemCategory.java @@ -7,6 +7,8 @@ import jenkins.model.Messages; /** * A category for {@link hudson.model.Item}s. + * + * @since TODO */ public abstract class ItemCategory implements ModelObject, ExtensionPoint { @@ -50,7 +52,7 @@ public abstract class ItemCategory implements ModelObject, ExtensionPoint { public abstract int getMinToShow(); /** - * The default category, if an item doesn't belong anywhere else, this is where it goes by default. + * The default {@link ItemCategory}, if an item doesn't belong anywhere else, this is where it goes by default. */ @Extension public static final class Default extends ItemCategory { diff --git a/core/src/main/java/jenkins/model/item_category/ItemCategoryConfigurator.java b/core/src/main/java/jenkins/model/item_category/ItemCategoryConfigurator.java index cf5d3b3338..62840566e9 100644 --- a/core/src/main/java/jenkins/model/item_category/ItemCategoryConfigurator.java +++ b/core/src/main/java/jenkins/model/item_category/ItemCategoryConfigurator.java @@ -11,6 +11,8 @@ import java.util.Collection; /** * A mapper of {@link ItemCategory}s to {@link hudson.model.Item}s. + * + * @since TODO */ public abstract class ItemCategoryConfigurator implements ExtensionPoint { @@ -19,7 +21,7 @@ public abstract class ItemCategoryConfigurator implements ExtensionPoint { * * @param descriptor the item to categorize * - * @return the category or null + * @return A {@link ItemCategory} or null */ @CheckForNull protected abstract ItemCategory getCategoryFor(@Nonnull TopLevelItemDescriptor descriptor); @@ -30,7 +32,7 @@ public abstract class ItemCategoryConfigurator implements ExtensionPoint { * * @param descriptor the item to categorize. * - * @return the category + * @return A {@link ItemCategory} */ @Nonnull public static ItemCategory getCategory(@Nonnull TopLevelItemDescriptor descriptor) { From 2356791978db17c19e767de7195ec07cb648b7a0 Mon Sep 17 00:00:00 2001 From: recena Date: Mon, 14 Mar 2016 13:56:08 +0100 Subject: [PATCH 028/366] [JENKINS-31162] A new description field has been added for Items --- .../java/hudson/model/ItemGroupMixIn.java | 2 + .../ItemCategoryConfigurator.java | 45 ++++++++++++++++--- 2 files changed, 42 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/hudson/model/ItemGroupMixIn.java b/core/src/main/java/hudson/model/ItemGroupMixIn.java index 417b9dac19..96913f748b 100644 --- a/core/src/main/java/hudson/model/ItemGroupMixIn.java +++ b/core/src/main/java/hudson/model/ItemGroupMixIn.java @@ -348,10 +348,12 @@ public abstract class ItemGroupMixIn { ItemCategory ic = ItemCategoryConfigurator.getCategory(descriptor); Map metadata = new HashMap(); + // Information about Item. metadata.put("class", descriptor.clazz.getName()); metadata.put("iconClassName", "item-icon-" + descriptor.clazz.getName().substring(descriptor.clazz.getName().lastIndexOf(".") + 1).toLowerCase()); metadata.put("weight", ItemCategoryConfigurator.getWeight(descriptor)); metadata.put("name", descriptor.getDisplayName()); + metadata.put("description", ItemCategoryConfigurator.getDescription(descriptor)); Category category = categories.getItem(ic.getId()); if (category != null) { diff --git a/core/src/main/java/jenkins/model/item_category/ItemCategoryConfigurator.java b/core/src/main/java/jenkins/model/item_category/ItemCategoryConfigurator.java index 62840566e9..925aac349f 100644 --- a/core/src/main/java/jenkins/model/item_category/ItemCategoryConfigurator.java +++ b/core/src/main/java/jenkins/model/item_category/ItemCategoryConfigurator.java @@ -56,12 +56,12 @@ public abstract class ItemCategoryConfigurator implements ExtensionPoint { protected abstract Integer getWeightFor(@Nonnull TopLevelItemDescriptor descriptor); /** - * Finds the category specified by the first mapper. - * If none can be found {@link ItemCategory.Default} is returned. + * Finds the weight specified by the first configurator. + * If none can be found {@link Integer#MIN_VALUE} is returned. {@see DefaultConfigurator#getWeightFor}. * * @param descriptor the item to categorize. * - * @return the category + * @return the weight */ @Nonnull public static Integer getWeight(@Nonnull TopLevelItemDescriptor descriptor) { @@ -71,7 +71,36 @@ public abstract class ItemCategoryConfigurator implements ExtensionPoint { return weight; } } - throw new IllegalStateException("At least, must exist the category: " + ItemCategory.Default.class); + throw new IllegalStateException("At least, a default value must exist"); + } + + /** + * Provides the description for the requested item or null if this configurator doesn't have one. + * + * @param descriptor the item to categorize + * + * @return A {@link ItemCategory} or null + */ + @CheckForNull + protected abstract String getDescriptionFor(@Nonnull TopLevelItemDescriptor descriptor); + + /** + * Finds the weight specified by the first configurator. + * If none can be found a empty string is returned. {@see DefaultConfigurator#getDescriptionFor}. + * + * @param descriptor the item to categorize. + * + * @return A {@link ItemCategory} + */ + @Nonnull + public static String getDescription(@Nonnull TopLevelItemDescriptor descriptor) { + for (ItemCategoryConfigurator m : all()) { + String description = m.getDescriptionFor(descriptor); + if (description != null) { + return description; + } + } + throw new IllegalStateException("At least, a default value must exist"); } public static Collection all() { @@ -79,7 +108,7 @@ public abstract class ItemCategoryConfigurator implements ExtensionPoint { } /** - * Mapper implementation with the lowest ordinal that simply returns {@link ItemCategory.Default}. + * Default configurator with the lowest ordinal that simply returns {@link ItemCategory.Default}. */ @Extension(ordinal = Integer.MIN_VALUE) public static final class DefaultConfigurator extends ItemCategoryConfigurator { @@ -96,5 +125,11 @@ public abstract class ItemCategoryConfigurator implements ExtensionPoint { return Integer.MIN_VALUE; } + @Nonnull + @Override + public String getDescriptionFor(@Nonnull TopLevelItemDescriptor descriptor) { + return ""; + } + } } From 21472bafa8fb5c383936a58080cb889729876638 Mon Sep 17 00:00:00 2001 From: recena Date: Mon, 14 Mar 2016 15:17:05 +0100 Subject: [PATCH 029/366] [JENKINS-31162] @daniel-beck's comment was addressed --- core/src/main/java/hudson/model/View.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/src/main/java/hudson/model/View.java b/core/src/main/java/hudson/model/View.java index 31bd89c94d..f8d4410c9e 100644 --- a/core/src/main/java/hudson/model/View.java +++ b/core/src/main/java/hudson/model/View.java @@ -64,6 +64,7 @@ import net.sf.json.JSON; import net.sf.json.JSONArray; import net.sf.json.JSONObject; import org.apache.tools.ant.filters.StringInputStream; +import org.kohsuke.accmod.restrictions.DoNotUse; import org.kohsuke.stapler.HttpResponse; import org.kohsuke.stapler.HttpResponses; import org.kohsuke.stapler.Stapler; @@ -1008,6 +1009,7 @@ public abstract class View extends AbstractModelObject implements AccessControll * * @since TODO */ + @Restricted(DoNotUse.class) public Categories doCategories(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { return ItemGroupMixIn.getCategories(Jenkins.getAuthentication(), Jenkins.getInstance()); } From 0b0b21d4d6f2e2e1c41680b7e0f6b9d84f9c86dc Mon Sep 17 00:00:00 2001 From: Manuel Recena Date: Mon, 14 Mar 2016 22:32:12 +0100 Subject: [PATCH 030/366] [JENKINS-31162] Category configuration reviewed --- .../jenkins/model/item_category/ItemCategory.java | 14 +++++++------- .../item_category/ItemCategoryConfigurator.java | 12 ++++++------ .../resources/jenkins/model/Messages.properties | 4 ++-- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/core/src/main/java/jenkins/model/item_category/ItemCategory.java b/core/src/main/java/jenkins/model/item_category/ItemCategory.java index 4bd8396169..2419ffde47 100644 --- a/core/src/main/java/jenkins/model/item_category/ItemCategory.java +++ b/core/src/main/java/jenkins/model/item_category/ItemCategory.java @@ -17,14 +17,14 @@ public abstract class ItemCategory implements ModelObject, ExtensionPoint { public static int MIN_TOSHOW = 1; /** - * Identifier, e.g. "category-id-default", etc. + * Identifier, e.g. "category-id-basicprojects", etc. * * @return the identifier */ public abstract String getId(); /** - * The icon class specification e.g. 'category-icon-folder', 'category-icon-default', etc. + * The icon class specification e.g. 'category-icon-folder', 'category-icon-basicprojects', etc. * * @return the icon class specification */ @@ -55,26 +55,26 @@ public abstract class ItemCategory implements ModelObject, ExtensionPoint { * The default {@link ItemCategory}, if an item doesn't belong anywhere else, this is where it goes by default. */ @Extension - public static final class Default extends ItemCategory { + public static final class BasicProjects extends ItemCategory { @Override public String getId() { - return "category-id-default"; + return "category-id-basicprojects"; } @Override public String getIconClassName() { - return "category-icon-default"; + return "category-icon-basicprojects"; } @Override public String getDescription() { - return Messages.ItemCategory_Default_Description(); + return Messages.ItemCategory_BasicProjects_Description(); } @Override public String getDisplayName() { - return Messages.ItemCategory_Default_DisplayName(); + return Messages.ItemCategory_BasicProjects_DisplayName(); } @Override diff --git a/core/src/main/java/jenkins/model/item_category/ItemCategoryConfigurator.java b/core/src/main/java/jenkins/model/item_category/ItemCategoryConfigurator.java index 925aac349f..f15e863f89 100644 --- a/core/src/main/java/jenkins/model/item_category/ItemCategoryConfigurator.java +++ b/core/src/main/java/jenkins/model/item_category/ItemCategoryConfigurator.java @@ -28,7 +28,7 @@ public abstract class ItemCategoryConfigurator implements ExtensionPoint { /** * Finds the category specified by the first configurator. - * If none can be found {@link ItemCategory.Default} is returned. + * If none can be found {@link ItemCategory.BasicProjects} is returned. * * @param descriptor the item to categorize. * @@ -42,7 +42,7 @@ public abstract class ItemCategoryConfigurator implements ExtensionPoint { return category; } } - throw new IllegalStateException("At least, must exist the category: " + ItemCategory.Default.class); + throw new IllegalStateException("At least, must exist the category: " + ItemCategory.BasicProjects.class); } /** @@ -71,7 +71,7 @@ public abstract class ItemCategoryConfigurator implements ExtensionPoint { return weight; } } - throw new IllegalStateException("At least, a default value must exist"); + throw new IllegalStateException("At least, a default value must exist for weight field"); } /** @@ -100,7 +100,7 @@ public abstract class ItemCategoryConfigurator implements ExtensionPoint { return description; } } - throw new IllegalStateException("At least, a default value must exist"); + throw new IllegalStateException("At least, a default value must exist for description field"); } public static Collection all() { @@ -108,7 +108,7 @@ public abstract class ItemCategoryConfigurator implements ExtensionPoint { } /** - * Default configurator with the lowest ordinal that simply returns {@link ItemCategory.Default}. + * Default configurator with the lowest ordinal that simply returns {@link ItemCategory.BasicProjects}. */ @Extension(ordinal = Integer.MIN_VALUE) public static final class DefaultConfigurator extends ItemCategoryConfigurator { @@ -116,7 +116,7 @@ public abstract class ItemCategoryConfigurator implements ExtensionPoint { @Nonnull @Override public ItemCategory getCategoryFor(@Nonnull TopLevelItemDescriptor descriptor) { - return ExtensionList.lookup(ItemCategory.Default.class).iterator().next(); + return ExtensionList.lookup(ItemCategory.BasicProjects.class).iterator().next(); } @Nonnull diff --git a/core/src/main/resources/jenkins/model/Messages.properties b/core/src/main/resources/jenkins/model/Messages.properties index 677d8d1f2a..7cad48704c 100644 --- a/core/src/main/resources/jenkins/model/Messages.properties +++ b/core/src/main/resources/jenkins/model/Messages.properties @@ -72,5 +72,5 @@ BlockedBecauseOfBuildInProgress.shortDescription=Build #{0} is already in progre BlockedBecauseOfBuildInProgress.ETA=\ (ETA:{0}) BuildDiscarderProperty.displayName=Discard Old Builds -ItemCategory.Default.DisplayName=Default/Unsorted -ItemCategory.Default.Description=Description +ItemCategory.BasicProjects.DisplayName=Basic Projects +ItemCategory.BasicProjects.Description=Create projects with a unique configuration and history. These projects can be standalone or grouped within Nested Projects. From c0bf2dee3708a4e5ddee0f80dfdf0c2fe45c8815 Mon Sep 17 00:00:00 2001 From: recena Date: Tue, 15 Mar 2016 13:04:17 +0100 Subject: [PATCH 031/366] [JENKINS-31162] @jglick's comment was addressed. A getEffectiveClazzFor() method was added to determine effective clazz of CustomOrganizationFolderDescriptor --- .../java/hudson/model/ItemGroupMixIn.java | 7 ++-- .../ItemCategoryConfigurator.java | 38 ++++++++++++++++++- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/hudson/model/ItemGroupMixIn.java b/core/src/main/java/hudson/model/ItemGroupMixIn.java index 96913f748b..79c19daeac 100644 --- a/core/src/main/java/hudson/model/ItemGroupMixIn.java +++ b/core/src/main/java/hudson/model/ItemGroupMixIn.java @@ -344,13 +344,14 @@ public abstract class ItemGroupMixIn { */ public static Categories getCategories(Authentication a, ItemGroup c) { Categories categories = new Categories(); - for (TopLevelItemDescriptor descriptor : Items.all(a, c)) { + for (TopLevelItemDescriptor descriptor : DescriptorVisibilityFilter.apply(c, Items.all(a, c))) { + String effectiveClazz = ItemCategoryConfigurator.getEffectiveClazz(descriptor); ItemCategory ic = ItemCategoryConfigurator.getCategory(descriptor); Map metadata = new HashMap(); // Information about Item. - metadata.put("class", descriptor.clazz.getName()); - metadata.put("iconClassName", "item-icon-" + descriptor.clazz.getName().substring(descriptor.clazz.getName().lastIndexOf(".") + 1).toLowerCase()); + metadata.put("class", effectiveClazz); + metadata.put("iconClassName", "item-icon-" + effectiveClazz.substring(descriptor.clazz.getName().lastIndexOf(".") + 1).toLowerCase()); metadata.put("weight", ItemCategoryConfigurator.getWeight(descriptor)); metadata.put("name", descriptor.getDisplayName()); metadata.put("description", ItemCategoryConfigurator.getDescription(descriptor)); diff --git a/core/src/main/java/jenkins/model/item_category/ItemCategoryConfigurator.java b/core/src/main/java/jenkins/model/item_category/ItemCategoryConfigurator.java index f15e863f89..9149c9193e 100644 --- a/core/src/main/java/jenkins/model/item_category/ItemCategoryConfigurator.java +++ b/core/src/main/java/jenkins/model/item_category/ItemCategoryConfigurator.java @@ -85,7 +85,7 @@ public abstract class ItemCategoryConfigurator implements ExtensionPoint { protected abstract String getDescriptionFor(@Nonnull TopLevelItemDescriptor descriptor); /** - * Finds the weight specified by the first configurator. + * Finds the description specified by the first configurator. * If none can be found a empty string is returned. {@see DefaultConfigurator#getDescriptionFor}. * * @param descriptor the item to categorize. @@ -103,12 +103,41 @@ public abstract class ItemCategoryConfigurator implements ExtensionPoint { throw new IllegalStateException("At least, a default value must exist for description field"); } + /** + * Provides the effective clazz for the requested item or null if this configurator doesn't have one. + * + * @param descriptor the item to categorize + * + * @return A string or null + */ + @CheckForNull + protected abstract String getEffectiveClazzFor(@Nonnull TopLevelItemDescriptor descriptor); + + /** + * Finds the weight specified by the first configurator. + * If none can be found a empty string with {@code descriptor.clazz.getName();} is returned. {@see DefaultConfigurator#getEffectiveClazzFor}. + * + * @param descriptor the item to categorize. + * + * @return A {@link ItemCategory} + */ + @Nonnull + public static String getEffectiveClazz(@Nonnull TopLevelItemDescriptor descriptor) { + for (ItemCategoryConfigurator m : all()) { + String clazz = m.getEffectiveClazzFor(descriptor); + if (clazz != null) { + return clazz; + } + } + throw new IllegalStateException("At least, a default value must exist for clazz field"); + } + public static Collection all() { return ExtensionList.lookup(ItemCategoryConfigurator.class); } /** - * Default configurator with the lowest ordinal that simply returns {@link ItemCategory.BasicProjects}. + * Default configurator with the lowest ordinal that simply returns default values. */ @Extension(ordinal = Integer.MIN_VALUE) public static final class DefaultConfigurator extends ItemCategoryConfigurator { @@ -131,5 +160,10 @@ public abstract class ItemCategoryConfigurator implements ExtensionPoint { return ""; } + @Nonnull + @Override + public String getEffectiveClazzFor(@Nonnull TopLevelItemDescriptor descriptor) { + return descriptor.clazz.getName(); + } } } From d204d57b82e45c03344269644d4e5301558f3f55 Mon Sep 17 00:00:00 2001 From: recena Date: Tue, 15 Mar 2016 15:23:20 +0100 Subject: [PATCH 032/366] [JENKINS-31162] A CopyCategory is returned when it makes sense --- core/src/main/java/hudson/model/ItemGroupMixIn.java | 5 +++++ .../model/item_category/ItemCategoryConfigurator.java | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/hudson/model/ItemGroupMixIn.java b/core/src/main/java/hudson/model/ItemGroupMixIn.java index 79c19daeac..00ea317243 100644 --- a/core/src/main/java/hudson/model/ItemGroupMixIn.java +++ b/core/src/main/java/hudson/model/ItemGroupMixIn.java @@ -367,6 +367,11 @@ public abstract class ItemGroupMixIn { categories.getItems().add(category); } } + if (Jenkins.getInstance().getAllItems().size() > 0) { + Category copy = new Category("category-id-copy", "Copy existing Item", "", "category-icon-copy", + ItemCategory.MIN_WEIGHT, ItemCategory.MIN_TOSHOW, new ArrayList>()); + categories.getItems().add(copy); + } return categories; } diff --git a/core/src/main/java/jenkins/model/item_category/ItemCategoryConfigurator.java b/core/src/main/java/jenkins/model/item_category/ItemCategoryConfigurator.java index 9149c9193e..4463edf2c3 100644 --- a/core/src/main/java/jenkins/model/item_category/ItemCategoryConfigurator.java +++ b/core/src/main/java/jenkins/model/item_category/ItemCategoryConfigurator.java @@ -85,7 +85,7 @@ public abstract class ItemCategoryConfigurator implements ExtensionPoint { protected abstract String getDescriptionFor(@Nonnull TopLevelItemDescriptor descriptor); /** - * Finds the description specified by the first configurator. + * Finds the weight specified by the first configurator. * If none can be found a empty string is returned. {@see DefaultConfigurator#getDescriptionFor}. * * @param descriptor the item to categorize. From 2bdcd5b7a988540ab09a236bce5b8a20dacf0683 Mon Sep 17 00:00:00 2001 From: recena Date: Tue, 15 Mar 2016 17:46:27 +0100 Subject: [PATCH 033/366] [JENKINS-31162] iconClassName field has been remove from Category entity. name field has been renamed to displayName --- .../main/java/hudson/model/ItemGroupMixIn.java | 16 +++++++++++----- .../jenkins/model/item_category/Category.java | 11 +---------- .../model/item_category/ItemCategory.java | 12 ------------ 3 files changed, 12 insertions(+), 27 deletions(-) diff --git a/core/src/main/java/hudson/model/ItemGroupMixIn.java b/core/src/main/java/hudson/model/ItemGroupMixIn.java index 00ea317243..9c0e6c929c 100644 --- a/core/src/main/java/hudson/model/ItemGroupMixIn.java +++ b/core/src/main/java/hudson/model/ItemGroupMixIn.java @@ -351,9 +351,8 @@ public abstract class ItemGroupMixIn { // Information about Item. metadata.put("class", effectiveClazz); - metadata.put("iconClassName", "item-icon-" + effectiveClazz.substring(descriptor.clazz.getName().lastIndexOf(".") + 1).toLowerCase()); metadata.put("weight", ItemCategoryConfigurator.getWeight(descriptor)); - metadata.put("name", descriptor.getDisplayName()); + metadata.put("displayName", descriptor.getDisplayName()); metadata.put("description", ItemCategoryConfigurator.getDescription(descriptor)); Category category = categories.getItem(ic.getId()); @@ -362,13 +361,20 @@ public abstract class ItemGroupMixIn { } else { List> temp = new ArrayList>(); temp.add(metadata); - category = new Category(ic.getId(), ic.getDisplayName(), ic.getDescription(), ic.getIconClassName(), - ic.getWeight(), ic.getMinToShow(), temp); + category = new Category(ic.getId(), ic.getDisplayName(), ic.getDescription(), ic.getWeight(), ic.getMinToShow(), temp); categories.getItems().add(category); } } if (Jenkins.getInstance().getAllItems().size() > 0) { - Category copy = new Category("category-id-copy", "Copy existing Item", "", "category-icon-copy", + Map metadata = new HashMap(); + + // Information about Item. + metadata.put("class", "copy"); + metadata.put("weight", Integer.MIN_VALUE); + metadata.put("displayName", ""); + metadata.put("description", ""); + + Category copy = new Category("category-id-copy", "Copy existing Item", "Use an existing item as a starting point for creating a new item configuration.", ItemCategory.MIN_WEIGHT, ItemCategory.MIN_TOSHOW, new ArrayList>()); categories.getItems().add(copy); } diff --git a/core/src/main/java/jenkins/model/item_category/Category.java b/core/src/main/java/jenkins/model/item_category/Category.java index c48bf257f1..9dde907ee3 100644 --- a/core/src/main/java/jenkins/model/item_category/Category.java +++ b/core/src/main/java/jenkins/model/item_category/Category.java @@ -22,20 +22,16 @@ public class Category implements Serializable { private String description; - private String iconClassName; - private int weight; private int minToShow; private List> items; - public Category(String id, String name, String description, String iconClassName, int weight, int minToShow, - List> items) { + public Category(String id, String name, String description, int weight, int minToShow, List> items) { this.id= id; this.name = name; this.description = description; - this.iconClassName = iconClassName; this.weight = weight; this.minToShow = minToShow; this.items = items; @@ -56,11 +52,6 @@ public class Category implements Serializable { return description; } - @Exported - public String getIconClassName() { - return iconClassName; - } - @Exported public int getWeight() { return weight; diff --git a/core/src/main/java/jenkins/model/item_category/ItemCategory.java b/core/src/main/java/jenkins/model/item_category/ItemCategory.java index 2419ffde47..c62e77d342 100644 --- a/core/src/main/java/jenkins/model/item_category/ItemCategory.java +++ b/core/src/main/java/jenkins/model/item_category/ItemCategory.java @@ -23,13 +23,6 @@ public abstract class ItemCategory implements ModelObject, ExtensionPoint { */ public abstract String getId(); - /** - * The icon class specification e.g. 'category-icon-folder', 'category-icon-basicprojects', etc. - * - * @return the icon class specification - */ - public abstract String getIconClassName(); - /** * The description in plain text * @@ -62,11 +55,6 @@ public abstract class ItemCategory implements ModelObject, ExtensionPoint { return "category-id-basicprojects"; } - @Override - public String getIconClassName() { - return "category-icon-basicprojects"; - } - @Override public String getDescription() { return Messages.ItemCategory_BasicProjects_Description(); From a39a7f8a098f9de1f6eda67cc20299a0cbc953a1 Mon Sep 17 00:00:00 2001 From: recena Date: Tue, 15 Mar 2016 19:30:11 +0100 Subject: [PATCH 034/366] [JENKINS-31162] Removed CopyCategory --- core/src/main/java/hudson/model/ItemGroupMixIn.java | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/core/src/main/java/hudson/model/ItemGroupMixIn.java b/core/src/main/java/hudson/model/ItemGroupMixIn.java index 9c0e6c929c..b34e502996 100644 --- a/core/src/main/java/hudson/model/ItemGroupMixIn.java +++ b/core/src/main/java/hudson/model/ItemGroupMixIn.java @@ -365,19 +365,6 @@ public abstract class ItemGroupMixIn { categories.getItems().add(category); } } - if (Jenkins.getInstance().getAllItems().size() > 0) { - Map metadata = new HashMap(); - - // Information about Item. - metadata.put("class", "copy"); - metadata.put("weight", Integer.MIN_VALUE); - metadata.put("displayName", ""); - metadata.put("description", ""); - - Category copy = new Category("category-id-copy", "Copy existing Item", "Use an existing item as a starting point for creating a new item configuration.", - ItemCategory.MIN_WEIGHT, ItemCategory.MIN_TOSHOW, new ArrayList>()); - categories.getItems().add(copy); - } return categories; } From b1ca4d91bc73d57c68b7b7b458b55a22bcd9e936 Mon Sep 17 00:00:00 2001 From: Manuel Recena Date: Wed, 16 Mar 2016 00:08:01 +0100 Subject: [PATCH 035/366] [JENKINS-31162] A new category (UncategorizedCategory) has been added --- .../java/jenkins/model/item_category/ItemCategory.java | 8 ++++---- .../model/item_category/ItemCategoryConfigurator.java | 6 +++--- core/src/main/resources/jenkins/model/Messages.properties | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/core/src/main/java/jenkins/model/item_category/ItemCategory.java b/core/src/main/java/jenkins/model/item_category/ItemCategory.java index c62e77d342..7e3607e2f3 100644 --- a/core/src/main/java/jenkins/model/item_category/ItemCategory.java +++ b/core/src/main/java/jenkins/model/item_category/ItemCategory.java @@ -48,21 +48,21 @@ public abstract class ItemCategory implements ModelObject, ExtensionPoint { * The default {@link ItemCategory}, if an item doesn't belong anywhere else, this is where it goes by default. */ @Extension - public static final class BasicProjects extends ItemCategory { + public static final class UncategorizedCategory extends ItemCategory { @Override public String getId() { - return "category-id-basicprojects"; + return "category-id-uncategorized"; } @Override public String getDescription() { - return Messages.ItemCategory_BasicProjects_Description(); + return Messages.ItemCategory_Uncategorized_Description(); } @Override public String getDisplayName() { - return Messages.ItemCategory_BasicProjects_DisplayName(); + return Messages.ItemCategory_Uncategorized_DisplayName(); } @Override diff --git a/core/src/main/java/jenkins/model/item_category/ItemCategoryConfigurator.java b/core/src/main/java/jenkins/model/item_category/ItemCategoryConfigurator.java index 4463edf2c3..683bed017e 100644 --- a/core/src/main/java/jenkins/model/item_category/ItemCategoryConfigurator.java +++ b/core/src/main/java/jenkins/model/item_category/ItemCategoryConfigurator.java @@ -28,7 +28,7 @@ public abstract class ItemCategoryConfigurator implements ExtensionPoint { /** * Finds the category specified by the first configurator. - * If none can be found {@link ItemCategory.BasicProjects} is returned. + * If none can be found {@link ItemCategory.UncategorizedCategory} is returned. * * @param descriptor the item to categorize. * @@ -42,7 +42,7 @@ public abstract class ItemCategoryConfigurator implements ExtensionPoint { return category; } } - throw new IllegalStateException("At least, must exist the category: " + ItemCategory.BasicProjects.class); + throw new IllegalStateException("At least, must exist the category: " + ItemCategory.UncategorizedCategory.class); } /** @@ -145,7 +145,7 @@ public abstract class ItemCategoryConfigurator implements ExtensionPoint { @Nonnull @Override public ItemCategory getCategoryFor(@Nonnull TopLevelItemDescriptor descriptor) { - return ExtensionList.lookup(ItemCategory.BasicProjects.class).iterator().next(); + return ExtensionList.lookup(ItemCategory.UncategorizedCategory.class).iterator().next(); } @Nonnull diff --git a/core/src/main/resources/jenkins/model/Messages.properties b/core/src/main/resources/jenkins/model/Messages.properties index 7cad48704c..a92122887c 100644 --- a/core/src/main/resources/jenkins/model/Messages.properties +++ b/core/src/main/resources/jenkins/model/Messages.properties @@ -72,5 +72,5 @@ BlockedBecauseOfBuildInProgress.shortDescription=Build #{0} is already in progre BlockedBecauseOfBuildInProgress.ETA=\ (ETA:{0}) BuildDiscarderProperty.displayName=Discard Old Builds -ItemCategory.BasicProjects.DisplayName=Basic Projects -ItemCategory.BasicProjects.Description=Create projects with a unique configuration and history. These projects can be standalone or grouped within Nested Projects. +ItemCategory.Uncategorized.DisplayName=Uncategorized +ItemCategory.Uncategorized.Description=Item types that have not yet been categorized by their plugin maintainer. From 467ab3ad5f371903dcfb6ae14135fcefc38549b0 Mon Sep 17 00:00:00 2001 From: Manuel Recena Date: Wed, 16 Mar 2016 00:14:25 +0100 Subject: [PATCH 036/366] [JENKINS-31162] Javadoc mistake --- .../jenkins/model/item_category/ItemCategoryConfigurator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/jenkins/model/item_category/ItemCategoryConfigurator.java b/core/src/main/java/jenkins/model/item_category/ItemCategoryConfigurator.java index 683bed017e..7c78a4ff17 100644 --- a/core/src/main/java/jenkins/model/item_category/ItemCategoryConfigurator.java +++ b/core/src/main/java/jenkins/model/item_category/ItemCategoryConfigurator.java @@ -114,7 +114,7 @@ public abstract class ItemCategoryConfigurator implements ExtensionPoint { protected abstract String getEffectiveClazzFor(@Nonnull TopLevelItemDescriptor descriptor); /** - * Finds the weight specified by the first configurator. + * Finds the effective clazz specified by the first configurator. * If none can be found a empty string with {@code descriptor.clazz.getName();} is returned. {@see DefaultConfigurator#getEffectiveClazzFor}. * * @param descriptor the item to categorize. From 602eca7b41bf9a7bbdc7918f5a29b8766219328f Mon Sep 17 00:00:00 2001 From: recena Date: Wed, 16 Mar 2016 13:05:26 +0100 Subject: [PATCH 037/366] [JENKINS-31162] A new API was added to handle Item icons --- .../java/hudson/model/ItemGroupMixIn.java | 1 + .../ItemCategoryConfigurator.java | 56 ++++++++++++++++--- 2 files changed, 48 insertions(+), 9 deletions(-) diff --git a/core/src/main/java/hudson/model/ItemGroupMixIn.java b/core/src/main/java/hudson/model/ItemGroupMixIn.java index b34e502996..cadcd39756 100644 --- a/core/src/main/java/hudson/model/ItemGroupMixIn.java +++ b/core/src/main/java/hudson/model/ItemGroupMixIn.java @@ -354,6 +354,7 @@ public abstract class ItemGroupMixIn { metadata.put("weight", ItemCategoryConfigurator.getWeight(descriptor)); metadata.put("displayName", descriptor.getDisplayName()); metadata.put("description", ItemCategoryConfigurator.getDescription(descriptor)); + metadata.put("iconFilePathPattern", ItemCategoryConfigurator.getIconFilePathPattern(descriptor)); Category category = categories.getItem(ic.getId()); if (category != null) { diff --git a/core/src/main/java/jenkins/model/item_category/ItemCategoryConfigurator.java b/core/src/main/java/jenkins/model/item_category/ItemCategoryConfigurator.java index 7c78a4ff17..ac75b8ba1c 100644 --- a/core/src/main/java/jenkins/model/item_category/ItemCategoryConfigurator.java +++ b/core/src/main/java/jenkins/model/item_category/ItemCategoryConfigurator.java @@ -19,7 +19,7 @@ public abstract class ItemCategoryConfigurator implements ExtensionPoint { /** * Provides the category for the requested item or null if this mapper doesn't have one. * - * @param descriptor the item to categorize + * @param descriptor the item it is asking about. * * @return A {@link ItemCategory} or null */ @@ -30,7 +30,7 @@ public abstract class ItemCategoryConfigurator implements ExtensionPoint { * Finds the category specified by the first configurator. * If none can be found {@link ItemCategory.UncategorizedCategory} is returned. * - * @param descriptor the item to categorize. + * @param descriptor the item it is asking about. * * @return A {@link ItemCategory} */ @@ -48,7 +48,7 @@ public abstract class ItemCategoryConfigurator implements ExtensionPoint { /** * Provides the weight for the requested item. Helpful to order a list. * - * @param descriptor the item to categorize + * @param descriptor the item it is asking about. * * @return the weight or null */ @@ -59,7 +59,7 @@ public abstract class ItemCategoryConfigurator implements ExtensionPoint { * Finds the weight specified by the first configurator. * If none can be found {@link Integer#MIN_VALUE} is returned. {@see DefaultConfigurator#getWeightFor}. * - * @param descriptor the item to categorize. + * @param descriptor the item it is asking about. * * @return the weight */ @@ -77,7 +77,7 @@ public abstract class ItemCategoryConfigurator implements ExtensionPoint { /** * Provides the description for the requested item or null if this configurator doesn't have one. * - * @param descriptor the item to categorize + * @param descriptor the item it is asking about. * * @return A {@link ItemCategory} or null */ @@ -88,7 +88,7 @@ public abstract class ItemCategoryConfigurator implements ExtensionPoint { * Finds the weight specified by the first configurator. * If none can be found a empty string is returned. {@see DefaultConfigurator#getDescriptionFor}. * - * @param descriptor the item to categorize. + * @param descriptor the item it is asking about. * * @return A {@link ItemCategory} */ @@ -106,7 +106,7 @@ public abstract class ItemCategoryConfigurator implements ExtensionPoint { /** * Provides the effective clazz for the requested item or null if this configurator doesn't have one. * - * @param descriptor the item to categorize + * @param descriptor the item it is asking about. * * @return A string or null */ @@ -117,9 +117,9 @@ public abstract class ItemCategoryConfigurator implements ExtensionPoint { * Finds the effective clazz specified by the first configurator. * If none can be found a empty string with {@code descriptor.clazz.getName();} is returned. {@see DefaultConfigurator#getEffectiveClazzFor}. * - * @param descriptor the item to categorize. + * @param descriptor the item it is asking about. * - * @return A {@link ItemCategory} + * @return A string */ @Nonnull public static String getEffectiveClazz(@Nonnull TopLevelItemDescriptor descriptor) { @@ -132,6 +132,37 @@ public abstract class ItemCategoryConfigurator implements ExtensionPoint { throw new IllegalStateException("At least, a default value must exist for clazz field"); } + /** + * Provides the icon path pattern for the requested item or null if this configurator doesn't have one. + * For example: /plugin/shortnme-of-myplugin/icons/item/:size:/myitem.pngm where :size should be replaced by the consumer using + * the standard sizes in Jenkins: 16x16, 24x24, etc... + * + * @param descriptor the item it is asking about. + * + * @return A string or null + */ + @CheckForNull + protected abstract String getIconFilePathPatternFor(@Nonnull TopLevelItemDescriptor descriptor); + + /** + * Finds the icon path pattern specified by the first configurator. + * If none can be found a empty string is returned. {@see DefaultConfigurator#getIconFilePathFor}. + * + * @param descriptor the item it is asking about. + * + * @return A string + */ + @Nonnull + public static String getIconFilePathPattern(@Nonnull TopLevelItemDescriptor descriptor) { + for (ItemCategoryConfigurator m : all()) { + String path = m.getIconFilePathPatternFor(descriptor); + if (path != null) { + return path; + } + } + throw new IllegalStateException("At least, a default value must exist for icon path pattern"); + } + public static Collection all() { return ExtensionList.lookup(ItemCategoryConfigurator.class); } @@ -165,5 +196,12 @@ public abstract class ItemCategoryConfigurator implements ExtensionPoint { public String getEffectiveClazzFor(@Nonnull TopLevelItemDescriptor descriptor) { return descriptor.clazz.getName(); } + + @Nonnull + @Override + public String getIconFilePathPatternFor(@Nonnull TopLevelItemDescriptor descriptor) { + return ""; + } + } } From 4adee7597aad7a338db8d3eb320575ae618a8c81 Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Wed, 16 Mar 2016 10:34:05 -0400 Subject: [PATCH 038/366] [JENKINS-33467] Clarifying that CauseAction.getCauses is immutable and you should construct the action with the causes you want. --- core/src/main/java/hudson/model/CauseAction.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/hudson/model/CauseAction.java b/core/src/main/java/hudson/model/CauseAction.java index 09e5b03274..b065715db8 100644 --- a/core/src/main/java/hudson/model/CauseAction.java +++ b/core/src/main/java/hudson/model/CauseAction.java @@ -82,14 +82,21 @@ public class CauseAction implements FoldableAction, RunAction2 { public CauseAction(CauseAction ca) { addCauses(ca.getCauses()); } - + + /** + * Lists all causes of this build. + * Note that the current implementation does not preserve insertion order of duplicates. + * @return an immutable list; + * to create an action with multiple causes use either of the constructors that support this; + * to append causes retroactively to a build you must create a new {@link CauseAction} and replace the old + */ @Exported(visibility=2) public List getCauses() { List r = new ArrayList<>(); for (Map.Entry entry : causeBag.entrySet()) { r.addAll(Collections.nCopies(entry.getValue(), entry.getKey())); } - return r; + return Collections.unmodifiableList(r); } /** From 08c205535d369bf6731cec58ccc16335771f2319 Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Wed, 16 Mar 2016 11:55:01 -0400 Subject: [PATCH 039/366] Setting font-size does in fact work here. --- war/src/main/webapp/css/style.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/war/src/main/webapp/css/style.css b/war/src/main/webapp/css/style.css index 654836ad0a..2bef219c25 100644 --- a/war/src/main/webapp/css/style.css +++ b/war/src/main/webapp/css/style.css @@ -1690,7 +1690,7 @@ table.progress-bar.red td.progress-bar-done { /* ========================= logRecords.jelly ================== */ .logrecord-metadata { - // TODO does not work: font-size: 70%; + font-size: 70%; } .logrecord-metadata-new { From 57fced93596b1f8bd69f00f154430a11530393de Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Wed, 16 Mar 2016 12:22:54 -0400 Subject: [PATCH 040/366] [FIXED JENKINS-18032] Crumbs must be appended when using post=true requiresConfirmation=true. --- core/src/main/resources/lib/layout/breadcrumbs.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/src/main/resources/lib/layout/breadcrumbs.js b/core/src/main/resources/lib/layout/breadcrumbs.js index 90b019f620..adbebc8435 100644 --- a/core/src/main/resources/lib/layout/breadcrumbs.js +++ b/core/src/main/resources/lib/layout/breadcrumbs.js @@ -61,6 +61,9 @@ var breadcrumbs = (function() { var form = document.createElement('form'); form.setAttribute('method', cfg.post ? 'POST' : 'GET'); form.setAttribute('action', cfg.url); + if (cfg.post) { + crumb.appendToForm(form); + } document.body.appendChild(form); form.submit(); } From 1d9ec2fb770dd41859abfba57b0d9add0710ecef Mon Sep 17 00:00:00 2001 From: Daniel Beck Date: Wed, 16 Mar 2016 18:42:29 +0100 Subject: [PATCH 041/366] Add a title for the confusing 'Use browser' option --- .../resources/jenkins/model/DownloadSettings/config.groovy | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/src/main/resources/jenkins/model/DownloadSettings/config.groovy b/core/src/main/resources/jenkins/model/DownloadSettings/config.groovy index 6b0751e563..f766281945 100644 --- a/core/src/main/resources/jenkins/model/DownloadSettings/config.groovy +++ b/core/src/main/resources/jenkins/model/DownloadSettings/config.groovy @@ -2,7 +2,8 @@ package jenkins.security.DownloadSettings def f = namespace(lib.FormTagLib) -// TODO avoid indentation somehow -f.entry(field: "useBrowser") { - f.checkbox(title: _("Use browser for metadata download")) +f.section(title:_("Plugin Manager")) { + f.entry(field: "useBrowser") { + f.checkbox(title: _("Use browser for metadata download")) + } } From 003f1e5b0c5ee076aa29ccb9296abf12f32481f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20Gond=C5=BEa?= Date: Wed, 16 Mar 2016 19:23:39 +0100 Subject: [PATCH 042/366] Towards 1.651.1 --- cli/pom.xml | 2 +- core/pom.xml | 2 +- pom.xml | 4 ++-- test/pom.xml | 2 +- war/pom.xml | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cli/pom.xml b/cli/pom.xml index 0a4446727d..614f4fb4f8 100644 --- a/cli/pom.xml +++ b/cli/pom.xml @@ -5,7 +5,7 @@ org.jenkins-ci.main pom - 1.651 + 1.651.1-SNAPSHOT cli diff --git a/core/pom.xml b/core/pom.xml index 4852592cab..4351e7e87b 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -29,7 +29,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 1.651 + 1.651.1-SNAPSHOT jenkins-core diff --git a/pom.xml b/pom.xml index c9af50a84a..103a9469df 100644 --- a/pom.xml +++ b/pom.xml @@ -33,7 +33,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 1.651 + 1.651.1-SNAPSHOT pom Jenkins main module @@ -58,7 +58,7 @@ THE SOFTWARE. scm:git:git://github.com/jenkinsci/jenkins.git scm:git:ssh://git@github.com/jenkinsci/jenkins.git https://github.com/jenkinsci/jenkins - jenkins-1.651 + HEAD diff --git a/test/pom.xml b/test/pom.xml index 0430e344e5..c3627abc29 100644 --- a/test/pom.xml +++ b/test/pom.xml @@ -28,7 +28,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 1.651 + 1.651.1-SNAPSHOT test diff --git a/war/pom.xml b/war/pom.xml index acaf96d382..c5b4c95719 100644 --- a/war/pom.xml +++ b/war/pom.xml @@ -28,7 +28,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 1.651 + 1.651.1-SNAPSHOT jenkins-war From 24d88543270ecc9611a621e2711f554a559f3870 Mon Sep 17 00:00:00 2001 From: gusreiber Date: Tue, 15 Mar 2016 15:06:05 -0700 Subject: [PATCH 043/366] fixing for 'displayName'...also gulpfule in --- war/gulpfile.js | 6 + war/src/main/js/add-item.js | 293 ++++++++++++++++++++++++++++++++++++ 2 files changed, 299 insertions(+) create mode 100644 war/src/main/js/add-item.js diff --git a/war/gulpfile.js b/war/gulpfile.js index cd1f43067a..6266fcbf49 100644 --- a/war/gulpfile.js +++ b/war/gulpfile.js @@ -30,3 +30,9 @@ builder.bundle('src/main/js/config-tabbar.js') .withExternalModuleMapping('jquery-detached', 'core-assets/jquery-detached:jquery2') .less('src/main/js/widgets/jenkins-widgets.less') .inDir('src/main/webapp/jsbundles'); + +builder.bundle('src/main/js/add-item.js') + .withExternalModuleMapping('jquery-detached', 'core-assets/jquery-detached:jquery2') + .less('src/main/js/widgets/jenkins-widgets.less') + .less('src/main/js/widgets/layout-mixins.less') + .inDir('src/main/webapp/jsbundles'); diff --git a/war/src/main/js/add-item.js b/war/src/main/js/add-item.js new file mode 100644 index 0000000000..91f46a7866 --- /dev/null +++ b/war/src/main/js/add-item.js @@ -0,0 +1,293 @@ +// Initialize all modules by requiring them. Also makes sure they get bundled (see gulpfile.js). +var $jq = require('jquery-detached').getJQuery(); + +var getItems = function(root){ + var $ = $jq; + var d = $.Deferred(); + $.get(root+'categories?depth=3').done( + function(data){ + d.resolve(data); + } + ); + return d.promise(); +}; + +var root = $jq('#jenkins').attr('data-root'); + +$jq.when(getItems(root)).done(function(data){ + $jq(function($) { + + ////////////////////////////// + // helpful reference DOM + + var jRoot = $('head').attr('data-rooturl'); + var defaultMinToShow = 2; + var $root = $jq('#main-panel'); + var $form = $root.find('form[name="createItem"]').addClass('jenkins-config new-view'); + var $newView = $jq('

') + .attr('name','createItem') + .attr('action','craetItem') + .prependTo($form); + var $tabs = $('
').appendTo($newView); + var $categories = $('
').appendTo($newView); + var sectionsToShow = []; + + + //////////////////////////////// + // scroll action...... + + function watchScroll(){ + var $window = $(window); + var $jenkTools = $('#breadcrumbBar'); + var winScoll = $window.scrollTop(); + var jenkToolOffset = $jenkTools.height() + $jenkTools.offset().top + 15; + + $tabs.find('.active').removeClass('active'); + $.each(data.categories,function(i,cat){ + var domId = '#j-add-item-type-'+cat.id; + var $cat = $(domId); + var catHeight = ($cat.length > 0)? + $cat.offset().top + $cat.outerHeight() - (jenkToolOffset + 100): + 0; + + if(winScoll < catHeight){ + var $thisTab = $tabs.find(['[href="',cleanHref(domId),'"]'].join('')); + resetActiveTab($thisTab); + return false; + } + }); + + if(winScoll > $('#page-head').height() - 5 ){ + $tabs.width($tabs.width()).css({ + 'position':'fixed', + 'top':($jenkTools.height() - 5 )+'px'}); + $categories.css({'margin-top':$tabs.outerHeight()+'px'}); + } + else{ + $tabs.add($categories).removeAttr('style'); + } + } + + ////////////////////////// + // helper functions... + + function addCopyOption(data){ + var $copy = $('#copy').closest('tr'); + if($copy.length === 0) return data; // exit if copy should not be added to page. Jelly page holds that logic. + var copyTitle = $copy.find('label').text(); + var copyDom = $copy.next().find('.setting-main').html(); + var copy = { + name:'Copy', + id:'copy', + minToShow:0, + weight:-999999999999, ///some really big number so it can be last... + items:[ + { + class:"copy", + description:copyDom, + name:copyTitle, + } + ] + }; + var newData = []; + + $.each(data,function(i,elem){ + if(elem.id !== "category-id-copy") + { newData.push(elem); } + }); + + newData.push(copy); + + + return newData; + } + + function sortItemsByOrder(itemTypes) { + function sortByOrder(a, b) { + var aOrder = a.weight; + var bOrder = b.weight; + return ( (aOrder < bOrder) ? -1 : ( (aOrder > bOrder) ? 1 : 0)); + } + return itemTypes.sort(sortByOrder); + } + + function hideAllTabsIfUnnecesary(sectionsToShow){ + if(sectionsToShow.length < 2){ + $tabs.find('.tab').hide(); + $categories.find('.category-header').hide(); + } + } + + function checkCatCount(elem){ + var minToShow = (typeof elem.minToShow === 'number')? elem.minToShow : 9999999; + return ($.isArray(elem.items) && elem.items.length >= Math.min(minToShow,defaultMinToShow)); + } + + function cleanClassName(className){ + return className.replace(/\./g,'_'); + } + + function cleanHref(id,reverse){ + if(reverse){ + var gotHash = (id.indexOf('#') === 0)? + '#j-add-item-type-'+ id.substring(1): + 'j-add-item-type-'+ id; + return gotHash; + } + else{ + return id.replace('j-add-item-type-',''); + } + } + + function cleanLayout(){ + // Do a little shimmy-hack to force legacy code to resize correctly and set tab state. + $('html,body').animate({scrollTop: 1}, 1); + $('html,body').animate({scrollTop: 0}, 10); + + setTimeout(fireBottomStickerAdjustEvent,410); + } + + function resetActiveTab($this){ + var $nav = $this.closest('.nav'); + $nav.find('.active').removeClass('active'); + $this.addClass('active'); + } + + ////////////////////////////////// + // Draw functions + + function drawName() { + var $name = $('
'); + + var $input = $('') + .change(function(){ + $form.find('input[name="name"]').val($(this).val()); + window.updateOk($form[0]); + }) + .appendTo($name); + + $tabs.prepend($name); + $input.focus(); + setTimeout(function(){$input.focus();},100); + } + + function drawTabs(data){ + $('body').addClass('add-item'); + setTimeout(function(){$('body').addClass('hide-side');},200); + $('#main-panel').addClass('container'); + var $navBox = $('