Class GlobalConfiguration
- All Implemented Interfaces:
ExtensionPoint
,Describable<GlobalConfiguration>
,Saveable
,Loadable
,OnMaster
- Direct Known Subclasses:
AdministrativeMonitorsConfiguration
,ApiTokenPropertyConfiguration
,ArtifactManagerConfiguration
,ConsoleUrlProviderGlobalConfiguration
,EnvVarsFilterGlobalConfiguration
,GlobalBuildDiscarderConfiguration
,GlobalComputerRetentionCheckIntervalConfiguration
,GlobalCrumbIssuerConfiguration
,GlobalDefaultViewConfiguration
,GlobalFingerprintConfiguration
,GlobalMavenConfig
,GlobalNodePropertiesConfiguration
,GlobalPluginConfiguration
,GlobalProjectNamingStrategyConfiguration
,GlobalQuietPeriodConfiguration
,GlobalSCMRetryCountConfiguration
,JenkinsLocationConfiguration
,MasterBuildConfiguration
,MyViewsTabBar.GlobalConfigurationImpl
,ProxyConfigurationManager
,QueueItemAuthenticatorConfiguration
,ResourceDomainConfiguration
,UpdateSiteWarningsConfiguration
,ViewsTabBar.GlobalConfigurationImpl
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
with global.groovy
or global.jelly
from your Descriptor
instance. However
each global.*
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(StaplerRequest2, JSONObject)
must be overridden,
in the normal case you would simply define persistable fields with getters and setters.
The config
view would use data-bound controls like f:entry
.
Then make sure your constructor calls Descriptor.load()
and your setters call Descriptor.save()
.
Views
Subtypes of this class should define a config.groovy
file or config.jelly
file
that gets pulled into the system configuration page.
Typically its contents should be wrapped in an f: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
-
Method Summary
Modifier and TypeMethodDescriptionstatic ExtensionList<GlobalConfiguration>
all()
Returns all the registeredGlobalConfiguration
descriptors.boolean
configure
(org.kohsuke.stapler.StaplerRequest2 req, net.sf.json.JSONObject json) By default, callsStaplerRequest2.bindJSON(Object, JSONObject)
, appropriate when your implementation has getters and setters for all fields.boolean
configure
(org.kohsuke.stapler.StaplerRequest req, net.sf.json.JSONObject json) Deprecated.final Descriptor<GlobalConfiguration>
Gets the descriptor for this instance.Methods inherited from class hudson.model.Descriptor
addHelpFileRedirect, bindJSON, bindJSON, calcAutoCompleteSettings, calcFillSettings, configure, doHelp, 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, getStaticHelpUrl, getStaticHelpUrl, getT, getViewPage, isInstance, isSubTypeOf, load, newInstance, newInstance, newInstance, newInstancesFromHeteroList, newInstancesFromHeteroList, newInstancesFromHeteroList, newInstancesFromHeteroList, save, self, toArray, toList, toMap
-
Constructor Details
-
GlobalConfiguration
protected GlobalConfiguration()
-
-
Method Details
-
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
- Overrides:
getGlobalConfigPage
in classDescriptor<GlobalConfiguration>
-
configure
public boolean configure(org.kohsuke.stapler.StaplerRequest2 req, net.sf.json.JSONObject json) throws Descriptor.FormException By default, callsStaplerRequest2.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
-
configure
@Deprecated public boolean configure(org.kohsuke.stapler.StaplerRequest req, net.sf.json.JSONObject json) throws Descriptor.FormException Deprecated.- Overrides:
configure
in classDescriptor<GlobalConfiguration>
- Throws:
Descriptor.FormException
-
all
Returns all the registeredGlobalConfiguration
descriptors.
-
configure(StaplerRequest2, JSONObject)