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.Self
-
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_SERVER_NAME
the default server name.static String
DISPLAY_NAME
What to call this plug-in to humans.static Permission
MANUAL_TRIGGER
The permission that allows users to perform theManualTriggerAction
.static PermissionGroup
PERMISSION_GROUP
Any special permissions needed by this plugin are grouped into this.static Permission
RETRIGGER
The permission that allows users to perform theRetriggerAction
.static String
SYMBOL_NAME
Machine readable plugin name.static String
TEST_SSH_KEYFILE_LOCATION_PROPERTY
System 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 Constructor Description PluginImpl()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description List<GerritServer>
addServer(GerritServer s)
Add a server to the list.boolean
containsServer(String serverName)
Check whether the list of servers contains a GerritServer object of a specific name.static boolean
containsServer_(String serverName)
Static shorthand forcontainsServer(String)
.protected static void
doXStreamRegistrations()
Registers XStream alias and converters to handle backwards compatibility with old data.static void
gerritStart()
Startup hook.static void
gerritStop()
Shutdown hook.Api
getApi()
Gets api.protected XmlFile
getConfigFile()
List<Job>
getConfiguredJobs(String serverName)
Return the list of jobs configured with a server.static List<Job>
getConfiguredJobs_(String serverName)
Static shorthand forgetConfiguredJobs(String)
.GerritServer
getFirstServer()
Gets the first server in the server list.static GerritServer
getFirstServer_()
Static shorthand forgetFirstServer()
.com.sonymobile.tools.gerrit.gerritevents.GerritHandler
getHandler()
Returns the GerritHandler object.static com.sonymobile.tools.gerrit.gerritevents.GerritHandler
getHandler_()
Static shorthand forgetHandler()
.static PluginImpl
getInstance()
Returns the instance of this class.PluginConfig
getPluginConfig()
Gets the global config.static PluginConfig
getPluginConfig_()
Gets the global config.GerritServer
getServer(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event)
Returns the Gerrit Server based on the GerritTriggerEvent.GerritServer
getServer(String name)
Get a GerritServer object by its name.static GerritServer
getServer_(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event)
Returns a GerritServer object based on a GerritTriggerEvent.static GerritServer
getServer_(String name)
Get a GerritServer object by its name.static IGerritHudsonTriggerConfig
getServerConfig(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event)
Finds the server config for the event's provider.List<String>
getServerNames()
Get the list of Gerrit server names.static List<String>
getServerNames_()
Static shorthand forgetServerNames()
.List<GerritServer>
getServers()
Get the list of Gerrit servers.static List<GerritServer>
getServers_()
Get the list of Gerrit servers.static void
initializeDispatchers()
Forces initialization of the Dispatchers.boolean
isActive()
Check if this plugin is active.void
load()
Load plugin config.List<GerritServer>
removeServer(GerritServer s)
Remove a server from the list.static void
save_()
Static shorthand forPlugin.save()
.void
setPluginConfig(PluginConfig pluginConfig)
Set plugin config.void
setServers(List<GerritServer> servers)
Set the list of Gerrit servers.void
start()
Start the plugin.void
stop()
Stop the plugin.-
Methods inherited from class jenkins.model.GlobalConfiguration
all, configure, getDescriptor, getGlobalConfigPage
-
Methods 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 Detail
-
DISPLAY_NAME
public static final String DISPLAY_NAME
What to call this plug-in to humans.- See Also:
- Constant Field Values
-
SYMBOL_NAME
public static final String SYMBOL_NAME
Machine readable plugin name.- See Also:
- Constant Field Values
-
PERMISSION_GROUP
public static final PermissionGroup PERMISSION_GROUP
Any special permissions needed by this plugin are grouped into this.
-
MANUAL_TRIGGER
public static final Permission MANUAL_TRIGGER
The permission that allows users to perform theManualTriggerAction
.
-
RETRIGGER
public static final Permission RETRIGGER
The permission that allows users to perform theRetriggerAction
.
-
DEFAULT_SERVER_NAME
public static final String DEFAULT_SERVER_NAME
the default server name.- See Also:
- Constant Field Values
-
TEST_SSH_KEYFILE_LOCATION_PROPERTY
public static final String TEST_SSH_KEYFILE_LOCATION_PROPERTY
System property used during testing to replace the location of the public key for mock connections.
-
-
Method Detail
-
getApi
public Api getApi()
Gets api.- Returns:
- the api.
-
getInstance
@CheckForNull public static PluginImpl 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
@Exported public List<GerritServer> getServers()
Get the list of Gerrit servers.- Returns:
- the list of GerritServers
-
getServers_
@NonNull public static List<GerritServer> 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
public List<String> getServerNames()
Get the list of Gerrit server names.- Returns:
- the list of server names as a list.
-
getServerNames_
@NonNull public static List<String> getServerNames_()
Static shorthand forgetServerNames()
.- Returns:
- the list of server names.
-
getServer
public GerritServer getServer(String name)
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_
@CheckForNull public static GerritServer getServer_(String name)
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(String)
-
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
@CheckForNull public GerritServer getFirstServer()
Gets the first server in the server list. Or null if there are no servers.- Returns:
- the server.
-
getFirstServer_
@CheckForNull public static GerritServer getFirstServer_()
Static shorthand forgetFirstServer()
.- Returns:
- the server if any.
-
setServers
public void setServers(List<GerritServer> servers)
Set the list of Gerrit servers.- Parameters:
servers
- the list to be set.
-
addServer
public List<GerritServer> addServer(GerritServer s)
Add a server to the list.- Parameters:
s
- the server to be added.- Returns:
- the list after adding the server.
-
removeServer
public List<GerritServer> removeServer(GerritServer s)
Remove a server from the list.- Parameters:
s
- the server to be removed.- Returns:
- the list after removing the server.
-
containsServer
public boolean containsServer(String serverName)
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_
public static boolean containsServer_(String serverName)
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
public PluginConfig getPluginConfig()
Gets the global config.- Returns:
- the config.
-
setPluginConfig
public void setPluginConfig(PluginConfig pluginConfig)
Set plugin config.- Parameters:
pluginConfig
- New config to set.
-
getPluginConfig_
@CheckForNull public static PluginConfig getPluginConfig_()
Gets the global config. Static short hand forgetPluginConfig()
.- Returns:
- the config.
-
save_
public static void save_() throws IOException
Static shorthand forPlugin.save()
.- Throws:
IOException
- if save does so.
-
getConfigFile
protected XmlFile getConfigFile()
- Overrides:
getConfigFile
in 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
public List<Job> getConfiguredJobs(String serverName)
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_
@NonNull public static List<Job> getConfiguredJobs_(String serverName)
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
@Initializer(after=SYSTEM_CONFIG_ADAPTED) public static void 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:
load
in 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.
-
-