Class GerritItemListener
- java.lang.Object
-
- hudson.model.listeners.ItemListener
-
- com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.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>
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
-
Constructor Summary
Constructors Constructor Description GerritItemListener()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
onDeleted(Item item)
Called by Jenkins when an item is about to be deleted.void
onLoaded()
Called by Jenkins when all items are loaded.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.-
Methods inherited from class hudson.model.listeners.ItemListener
all, checkBeforeCopy, fireLocationChange, fireOnCopied, fireOnCreated, fireOnDeleted, fireOnUpdated, onBeforeShutdown, onCheckCopy, onCopied, onCreated, onRenamed, onUpdated, register
-
-
-
-
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 classItemListener
- 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 classItemListener
- Parameters:
item
- an item whose absolute position is now differentoldFullName
- the formerItem.getFullName()
newFullName
- the currentItem.getFullName()
-
onLoaded
public void onLoaded()
Called by Jenkins when all items are loaded.- Overrides:
onLoaded
in classItemListener
-
-