Class PluginImpl
java.lang.Object
hudson.model.Descriptor<GlobalConfiguration>
jenkins.model.GlobalConfiguration
com.sonyericsson.hudson.plugins.gerrit.trigger.PluginImpl
- All Implemented Interfaces:
ExtensionPoint,Describable<GlobalConfiguration>,Saveable,OnMaster
@ExportedBean
@Extension
@Symbol("gerrit-trigger")
public class PluginImpl
extends GlobalConfiguration
Main Plugin entrance.
- Author:
- Robert Sandell <robert.sandell@sonyericsson.com>
-
Nested Class Summary
Nested classes/interfaces inherited from class hudson.model.Descriptor
Descriptor.FormException, Descriptor.PropertyType, Descriptor.SelfNested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringthe default server name.static final StringWhat to call this plug-in to humans.static final PermissionThe permission that allows users to perform theManualTriggerAction.static final PermissionGroupAny special permissions needed by this plugin are grouped into this.static final PermissionThe permission that allows users to perform theRetriggerAction.static final StringMachine readable plugin name.static final StringSystem property used during testing to replace the location of the public key for mock connections.Fields inherited from class hudson.model.Descriptor
clazz -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdd a server to the list.booleancontainsServer(String serverName) Check whether the list of servers contains a GerritServer object of a specific name.static booleancontainsServer_(String serverName) Static shorthand forcontainsServer(String).protected static voidRegisters XStream alias and converters to handle backwards compatibility with old data.static voidStartup hook.static voidShutdown hook.getApi()Gets api.protected XmlFilegetConfiguredJobs(String serverName) Return the list of jobs configured with a server.getConfiguredJobs_(String serverName) Static shorthand forgetConfiguredJobs(String).Gets the first server in the server list.static GerritServerStatic shorthand forgetFirstServer().com.sonymobile.tools.gerrit.gerritevents.GerritHandlerReturns the GerritHandler object.static com.sonymobile.tools.gerrit.gerritevents.GerritHandlerStatic shorthand forgetHandler().static PluginImplReturns the instance of this class.Gets the global config.static PluginConfigGets the global config.getServer(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event) Returns the Gerrit Server based on the GerritTriggerEvent.Get a GerritServer object by its name.static GerritServergetServer_(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event) Returns a GerritServer object based on a GerritTriggerEvent.static GerritServergetServer_(String name) Get a GerritServer object by its name.static IGerritHudsonTriggerConfiggetServerConfig(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event) Finds the server config for the event's provider.Get the list of Gerrit server names.Static shorthand forgetServerNames().Get the list of Gerrit servers.static List<GerritServer>Get the list of Gerrit servers.static voidForces initialization of the Dispatchers.booleanisActive()Check if this plugin is active.voidload()Load plugin config.Remove a server from the list.static voidsave_()Static shorthand forPlugin.save().voidsetPluginConfig(PluginConfig pluginConfig) Set plugin config.voidsetServers(List<GerritServer> servers) Set the list of Gerrit servers.voidstart()Start the plugin.voidstop()Stop the plugin.Methods inherited from class jenkins.model.GlobalConfiguration
all, configure, getDescriptor, getGlobalConfigPageMethods inherited from class hudson.model.Descriptor
addHelpFileRedirect, bindJSON, calcAutoCompleteSettings, calcFillSettings, configure, doHelp, find, find, findByDescribableClassName, findById, getCategory, getCheckMethod, getCheckUrl, getConfigPage, getCurrentDescriptorByNameUrl, getDescriptorFullUrl, getDescriptorUrl, getDisplayName, getGlobalPropertyType, getHelpFile, getHelpFile, getHelpFile, getId, getJsonSafeClassName, getKlass, getPlugin, getPossibleViewNames, getPropertyType, getPropertyType, getPropertyTypeOrDie, getRequiredGlobalConfigPagePermission, getT, getViewPage, isInstance, isSubTypeOf, newInstance, newInstance, newInstancesFromHeteroList, newInstancesFromHeteroList, save, self, toArray, toList, toMap
-
Field Details
-
DISPLAY_NAME
What to call this plug-in to humans.- See Also:
-
SYMBOL_NAME
Machine readable plugin name.- See Also:
-
PERMISSION_GROUP
Any special permissions needed by this plugin are grouped into this. -
MANUAL_TRIGGER
The permission that allows users to perform theManualTriggerAction. -
RETRIGGER
The permission that allows users to perform theRetriggerAction. -
DEFAULT_SERVER_NAME
the default server name.- See Also:
-
TEST_SSH_KEYFILE_LOCATION_PROPERTY
System property used during testing to replace the location of the public key for mock connections.
-
-
Constructor Details
-
PluginImpl
public PluginImpl()
-
-
Method Details
-
getApi
Gets api.- Returns:
- the api.
-
getInstance
Returns the instance of this class. IfJenkins.getInstanceOrNull()()} isn't available or the plugin class isn't registered null will be returned.- Returns:
- the instance.
-
isActive
public boolean isActive()Check if this plugin is active.- Returns:
- true if active.
-
getServers
Get the list of Gerrit servers.- Returns:
- the list of GerritServers
-
getServers_
Get the list of Gerrit servers. Static shorthand forgetServers(). If the plugin instance is not available, and empty list is returned.- Returns:
- the list of GerritServers
-
getServerNames
Get the list of Gerrit server names.- Returns:
- the list of server names as a list.
-
getServerNames_
Static shorthand forgetServerNames().- Returns:
- the list of server names.
-
getServer
Get a GerritServer object by its name.- Parameters:
name- the name of the server to get.- Returns:
- the GerritServer object to get, or null if no server has this name.
-
getServer_
Get a GerritServer object by its name. Static short forgetServer(String).- Parameters:
name- the name of the server to get.- Returns:
- the GerritServer object to get, or null if no server has this name.
- See Also:
-
getServer
public GerritServer getServer(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event) Returns the Gerrit Server based on the GerritTriggerEvent.- Parameters:
event- The GerritTriggerEvent.- Returns:
- GerritServer or null if no server could be found.
-
getServer_
@CheckForNull public static GerritServer getServer_(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event) Returns a GerritServer object based on a GerritTriggerEvent. Static short forgetServer(GerritTriggeredEvent).- Parameters:
event- The GerritTriggerEvent.- Returns:
- GerritServer or null if no server could be found.
-
getFirstServer
Gets the first server in the server list. Or null if there are no servers.- Returns:
- the server.
-
getFirstServer_
Static shorthand forgetFirstServer().- Returns:
- the server if any.
-
setServers
Set the list of Gerrit servers.- Parameters:
servers- the list to be set.
-
addServer
Add a server to the list.- Parameters:
s- the server to be added.- Returns:
- the list after adding the server.
-
removeServer
Remove a server from the list.- Parameters:
s- the server to be removed.- Returns:
- the list after removing the server.
-
containsServer
Check whether the list of servers contains a GerritServer object of a specific name.- Parameters:
serverName- to check.- Returns:
- whether the list contains a server with the given name.
-
containsServer_
Static shorthand forcontainsServer(String).- Parameters:
serverName- to check.- Returns:
- whether the list contains a server with the given name.
-
getServerConfig
public static IGerritHudsonTriggerConfig getServerConfig(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event) Finds the server config for the event's provider.- Parameters:
event- the event- Returns:
- the config or null if no server could be found.
- See Also:
-
GerritTriggeredEvent.getProvider()
-
getPluginConfig
Gets the global config.- Returns:
- the config.
-
setPluginConfig
Set plugin config.- Parameters:
pluginConfig- New config to set.
-
getPluginConfig_
Gets the global config. Static short hand forgetPluginConfig().- Returns:
- the config.
-
save_
Static shorthand forPlugin.save().- Throws:
IOException- if save does so.
-
getConfigFile
- Overrides:
getConfigFilein classDescriptor<GlobalConfiguration>
-
getHandler
@NonNull public com.sonymobile.tools.gerrit.gerritevents.GerritHandler getHandler()Returns the GerritHandler object.- Returns:
- gerritEventManager
-
getHandler_
@CheckForNull public static com.sonymobile.tools.gerrit.gerritevents.GerritHandler getHandler_()Static shorthand forgetHandler().- Returns:
- gerritEventManager
-
getConfiguredJobs
Return the list of jobs configured with a server.- Parameters:
serverName- the name of the Gerrit server.- Returns:
- the list of jobs configured with this server.
-
getConfiguredJobs_
Static shorthand forgetConfiguredJobs(String). Will return an empty list if plugin instance is null.- Parameters:
serverName- the name of the Gerrit server.- Returns:
- the list of jobs configured with this server.
-
start
public void start()Start the plugin. -
initializeDispatchers
Forces initialization of the Dispatchers. They need to register and listen to GerritEvents. Normally, it is lazy loaded when the first build is started. -
load
public void load()Load plugin config.- Overrides:
loadin classDescriptor<GlobalConfiguration>
-
doXStreamRegistrations
protected static void doXStreamRegistrations()Registers XStream alias and converters to handle backwards compatibility with old data. -
stop
public void stop()Stop the plugin. -
gerritStart
@Initializer(after=PLUGINS_STARTED, before=EXTENSIONS_AUGMENTED) @Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class) public static void gerritStart()Startup hook. -
gerritStop
@Terminator(after=COMPLETED) @Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class) public static void gerritStop()Shutdown hook.
-