public abstract class GlobalConfiguration extends Descriptor<GlobalConfiguration> implements ExtensionPoint, Describable<GlobalConfiguration>
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 other Extension
s (so this does not work
for classes not annotated with Extension
)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.
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()
.
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
.
Descriptor.FormException, Descriptor.PropertyType, Descriptor.Self
ExtensionPoint.LegacyInstancesAreScopedToHudson
clazz
Modifier | Constructor and Description |
---|---|
protected |
GlobalConfiguration() |
Modifier and Type | Method and Description |
---|---|
static ExtensionList<GlobalConfiguration> |
all()
Returns all the registered
GlobalConfiguration descriptors. |
boolean |
configure(org.kohsuke.stapler.StaplerRequest req,
net.sf.json.JSONObject json)
By default, calls
StaplerRequest.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() |
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
public final Descriptor<GlobalConfiguration> getDescriptor()
Describable
Descriptor
is a singleton for every concrete Describable
implementation, so if a.getClass() == b.getClass()
then by default
a.getDescriptor() == b.getDescriptor()
as well.
(In rare cases a single implementation class may be used for instances with distinct descriptors.)
getDescriptor
in interface Describable<GlobalConfiguration>
public String getGlobalConfigPage()
getGlobalConfigPage
in class Descriptor<GlobalConfiguration>
public boolean configure(org.kohsuke.stapler.StaplerRequest req, net.sf.json.JSONObject json) throws Descriptor.FormException
StaplerRequest.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.
configure
in class Descriptor<GlobalConfiguration>
json
- The JSON object that captures the configuration data for this Descriptor
.
See https://www.jenkins.io/doc/developer/forms/structured-form-submission/Descriptor.FormException
@NonNull public static ExtensionList<GlobalConfiguration> all()
GlobalConfiguration
descriptors.Copyright © 2004–2022. All rights reserved.