Class PluginImpl

    • Field Detail

      • PERMISSION_GROUP

        public static final PermissionGroup PERMISSION_GROUP
        Any special permissions needed by this plugin are grouped into this.
      • 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.
    • Constructor Detail

      • PluginImpl

        public PluginImpl()
    • Method Detail

      • getApi

        public Api getApi()
        Gets api.
        Returns:
        the api.
      • getInstance

        @CheckForNull
        public static PluginImpl getInstance()
        Returns the instance of this class. If Jenkins.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 for getServers(). 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 for getServerNames().
        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 for getServer(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 for getServer(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 for getFirstServer().
        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 for containsServer(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 for getPluginConfig().
        Returns:
        the config.
      • 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 for getHandler().
        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 for getConfiguredJobs(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.
      • doXStreamRegistrations

        protected static void doXStreamRegistrations()
        Registers XStream alias and converters to handle backwards compatibility with old data.
      • stop

        public void stop()
        Stop the plugin.
      • gerritStop

        @Terminator(after=COMPLETED)
        @Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class)
        public static void gerritStop()
        Shutdown hook.