From 48e801023123f84ee4eebf60737089f41b44958e Mon Sep 17 00:00:00 2001 From: Stephen Connolly Date: Tue, 18 Jun 2013 10:54:12 +0100 Subject: [PATCH] [JENKINS-18381] Provide a mechanism to differentiate between node properties that are applicable to the master node only and node properties that can be applied to all nodes --- changelog.html | 4 ++++ core/src/main/java/hudson/Functions.java | 16 ++++++++++++++++ .../hudson/slaves/NodePropertyDescriptor.java | 14 ++++++++++++++ .../config.groovy | 2 +- 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/changelog.html b/changelog.html index 395c7e201a..1487d5f3de 100644 --- a/changelog.html +++ b/changelog.html @@ -90,6 +90,10 @@ Upcoming changes
  • CLI list-jobs command should list all nested jobs. (pull request 793) +
  • + Provide a mechanism to differentiate between node properties that are applicable + to the master node only and node properties that can be applied to all nodes + (issue 18381) diff --git a/core/src/main/java/hudson/Functions.java b/core/src/main/java/hudson/Functions.java index d922f3310e..781afece9c 100644 --- a/core/src/main/java/hudson/Functions.java +++ b/core/src/main/java/hudson/Functions.java @@ -796,6 +796,22 @@ public class Functions { return result; } + /** + * Returns those node properties which can be configured as global node properties. + * + * @since 1.520 + */ + public static List getGlobalNodePropertyDescriptors() { + List result = new ArrayList(); + Collection list = (Collection) Jenkins.getInstance().getDescriptorList(NodeProperty.class); + for (NodePropertyDescriptor npd : list) { + if (npd.isApplicableAsGlobal()) { + result.add(npd); + } + } + return result; + } + /** * Gets all the descriptors sorted by their inheritance tree of {@link Describable} * so that descriptors of similar types come nearby. diff --git a/core/src/main/java/hudson/slaves/NodePropertyDescriptor.java b/core/src/main/java/hudson/slaves/NodePropertyDescriptor.java index 2f42f5a280..823ddb6eec 100644 --- a/core/src/main/java/hudson/slaves/NodePropertyDescriptor.java +++ b/core/src/main/java/hudson/slaves/NodePropertyDescriptor.java @@ -26,6 +26,7 @@ package hudson.slaves; import hudson.Extension; import hudson.model.Node; import hudson.tools.PropertyDescriptor; +import jenkins.model.Jenkins; /** * Descriptor for {@link NodeProperty}. @@ -43,4 +44,17 @@ public abstract class NodePropertyDescriptor extends PropertyDescriptor