Class GlobalConfiguration
- java.lang.Object
-
- hudson.model.Descriptor<GlobalConfiguration>
-
- jenkins.model.GlobalConfiguration
-
- All Implemented Interfaces:
ExtensionPoint
,Describable<GlobalConfiguration>
,Saveable
,OnMaster
- Direct Known Subclasses:
AdministrativeMonitorsConfiguration
,ApiTokenPropertyConfiguration
,ArtifactManagerConfiguration
,EnvVarsFilterGlobalConfiguration
,GlobalBuildDiscarderConfiguration
,GlobalCrumbIssuerConfiguration
,GlobalDefaultViewConfiguration
,GlobalFingerprintConfiguration
,GlobalMavenConfig
,GlobalNodePropertiesConfiguration
,GlobalPluginConfiguration
,GlobalProjectNamingStrategyConfiguration
,GlobalQuietPeriodConfiguration
,GlobalSCMRetryCountConfiguration
,JenkinsLocationConfiguration
,MasterBuildConfiguration
,MyViewsTabBar.GlobalConfigurationImpl
,QueueItemAuthenticatorConfiguration
,ResourceDomainConfiguration
,UpdateSiteWarningsConfiguration
,ViewsTabBar.GlobalConfigurationImpl
public abstract class GlobalConfiguration extends Descriptor<GlobalConfiguration> implements ExtensionPoint, Describable<GlobalConfiguration>
Convenient base class for extensions that contributes to the system configuration page but nothing else, or to manage the global configuration of a plugin implementing several extension points.All
Descriptor
s are capable of contributing fragment to the system config page. If you are implementing other extension points that need to expose some global configuration, you can do so withglobal.groovy
orglobal.jelly
from yourDescriptor
instance. However eachglobal.*
file will appear as its own section in the global configuration page.An option to present a single section for your plugin in the Jenkins global configuration page is to use this class to manage the configuration for your plugin and its extension points. To access properties defined in your GlobalConfiguration subclass, here are two possibilities:
- @
Inject
into your otherExtension
s (so this does not work for classes not annotated withExtension
) - access it via a call to
ExtensionList.lookupSingleton(<your GlobalConfiguration subclass>.class)
While an implementation might store its actual configuration data in various ways, meaning
configure(StaplerRequest, JSONObject)
must be overridden, in the normal case you would simply define persistable fields with getters and setters. Theconfig
view would use data-bound controls likef:entry
. Then make sure your constructor callsDescriptor.load()
and your setters callDescriptor.save()
.Views
Subtypes of this class should define a
config.groovy
file orconfig.jelly
file that gets pulled into the system configuration page. Typically its contents should be wrapped in anf:section
.- Since:
- 1.425
- Author:
- Kohsuke Kawaguchi
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class hudson.model.Descriptor
Descriptor.FormException, Descriptor.PropertyType, Descriptor.Self
-
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
-
Field Summary
-
Fields inherited from class hudson.model.Descriptor
clazz
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
GlobalConfiguration()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ExtensionList<GlobalConfiguration>
all()
Returns all the registeredGlobalConfiguration
descriptors.boolean
configure(org.kohsuke.stapler.StaplerRequest req, net.sf.json.JSONObject json)
By default, callsStaplerRequest.bindJSON(Object, JSONObject)
, appropriate when your implementation has getters and setters for all fields.Descriptor<GlobalConfiguration>
getDescriptor()
Gets the descriptor for this instance.String
getGlobalConfigPage()
-
Methods inherited from class hudson.model.Descriptor
addHelpFileRedirect, bindJSON, calcAutoCompleteSettings, calcFillSettings, configure, doHelp, find, find, findByDescribableClassName, findById, getCategory, getCheckMethod, getCheckUrl, getConfigFile, getConfigPage, getCurrentDescriptorByNameUrl, getDescriptorFullUrl, getDescriptorUrl, getDisplayName, getGlobalPropertyType, getHelpFile, getHelpFile, getHelpFile, getId, getJsonSafeClassName, getKlass, getPlugin, getPossibleViewNames, getPropertyType, getPropertyType, getPropertyTypeOrDie, getRequiredGlobalConfigPagePermission, getT, getViewPage, isInstance, isSubTypeOf, load, newInstance, newInstance, newInstancesFromHeteroList, newInstancesFromHeteroList, save, self, toArray, toList, toMap
-
-
-
-
Method Detail
-
getDescriptor
public final Descriptor<GlobalConfiguration> getDescriptor()
Description copied from interface:Describable
Gets the descriptor for this instance.Descriptor
is a singleton for every concreteDescribable
implementation, so ifa.getClass() == b.getClass()
then by defaulta.getDescriptor() == b.getDescriptor()
as well. (In rare cases a single implementation class may be used for instances with distinct descriptors.)- Specified by:
getDescriptor
in interfaceDescribable<GlobalConfiguration>
-
getGlobalConfigPage
public String getGlobalConfigPage()
- Overrides:
getGlobalConfigPage
in classDescriptor<GlobalConfiguration>
-
configure
public boolean configure(org.kohsuke.stapler.StaplerRequest req, net.sf.json.JSONObject json) throws Descriptor.FormException
By default, callsStaplerRequest.bindJSON(Object, JSONObject)
, appropriate when your implementation has getters and setters for all fields.Invoked when the global configuration page is submitted. Can be overridden to store descriptor-specific information.
- Overrides:
configure
in classDescriptor<GlobalConfiguration>
json
- The JSON object that captures the configuration data for thisDescriptor
. See the developer documentation.- Returns:
- false to keep the client in the same config page.
- Throws:
Descriptor.FormException
-
all
@NonNull public static ExtensionList<GlobalConfiguration> all()
Returns all the registeredGlobalConfiguration
descriptors.
-
-