Class GerritItemListener

  • All Implemented Interfaces:
    ExtensionPoint

    @Extension
    public class GerritItemListener
    extends ItemListener
    Listens for onDeleted and onLoaded events. If the deleted project has a Gerrit trigger, it will be stopped If all project have been loaded, start the connections to Gerrit servers. Since this class has no member variables, and doesn't need any initialization, there is no constructor.
    Author:
    Fredrik Abrahamson <fredrik.abrahamson@sonymobile.com>
    • Constructor Detail

      • GerritItemListener

        public GerritItemListener()
    • Method Detail

      • onDeleted

        public void onDeleted​(Item item)
        Called by Jenkins when an item is about to be deleted. If this item is a project (Job or any of its subclasses), then we check if it has a GerritTrigger among its triggers. If so, call the trigger's stop() method. It removes deleted project from all ongoing builds, so, GerritTrigger will not wait projects that do not have chance to be finished. Also this class is unfortunately needed because Jenkins doesn't call Trigger.stop() when a project is deleted, only when a project is reconfigured. Thus we need this class to remove the listener and cancel the timer when a project is deleted.
        Overrides:
        onDeleted in class ItemListener
        Parameters:
        item - the item that will be deleted, it is interesting if it is a subclass of an Job
      • onLocationChanged

        public void onLocationChanged​(Item item,
                                      String oldFullName,
                                      String newFullName)
        trigger get stopped/started when a job is configured, but rename is a special operation and uses a two phase confirmation, the second one doing the actual rename does not stop/start the trigger, so we end up with misconfigured EventListener. Also see JENKINS-22936
        Overrides:
        onLocationChanged in class ItemListener
        Parameters:
        item - an item whose absolute position is now different
        oldFullName - the former Item.getFullName()
        newFullName - the current Item.getFullName()
      • onLoaded

        public void onLoaded()
        Called by Jenkins when all items are loaded.
        Overrides:
        onLoaded in class ItemListener