com.sonyericsson.hudson.plugins.gerrit.trigger.gerritnotifier
Class ToGerritRunListener

java.lang.Object
  extended by hudson.model.listeners.RunListener<hudson.model.AbstractBuild>
      extended by com.sonyericsson.hudson.plugins.gerrit.trigger.gerritnotifier.ToGerritRunListener
All Implemented Interfaces:
hudson.ExtensionPoint

@Extension
public class ToGerritRunListener
extends hudson.model.listeners.RunListener<hudson.model.AbstractBuild>

The Big RunListener in charge of coordinating build results and reporting back to Gerrit.

Author:
Robert Sandell <robert.sandell@sonyericsson.com>

Nested Class Summary
 
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
hudson.ExtensionPoint.LegacyInstancesAreScopedToHudson
 
Field Summary
 
Fields inherited from class hudson.model.listeners.RunListener
LISTENERS, targetType
 
Constructor Summary
ToGerritRunListener()
          Default Constructor.
 
Method Summary
protected  void cleanUpGerritCauses(GerritCause firstFound, hudson.model.AbstractBuild build)
          Workaround for builds that are triggered by the same Gerrit cause but multiple times in the same quiet period.
static ToGerritRunListener getInstance()
          Returns the registered instance of this class from the list of all listeners.
 boolean isBuilding(hudson.model.AbstractProject project, PatchsetCreated event)
          Checks the memory if the project is currently building the event.
 boolean isBuilding(PatchsetCreated event)
          Checks the memory if the event is building.
 void onCompleted(hudson.model.AbstractBuild r, hudson.model.TaskListener listener)
           
 void onRetriggered(hudson.model.AbstractProject project, PatchsetCreated event, List<hudson.model.AbstractBuild> otherBuilds)
          Called just before a build is scheduled by the user to retrigger.
 void onStarted(hudson.model.AbstractBuild r, hudson.model.TaskListener listener)
           
 void onTriggered(hudson.model.AbstractProject project, PatchsetCreated event)
          Called just before a build is scheduled by the trigger.
protected  void setThisBuild(hudson.model.AbstractBuild r)
          Updates all GerritCauses TriggerContext.thisBuild in the build.
protected  void updateTriggerContexts(hudson.model.AbstractBuild r, BuildMemory.PatchSetKey key)
          Updates the TriggerContexts for all the GerritCauses in the build.
 
Methods inherited from class hudson.model.listeners.RunListener
all, fireCompleted, fireDeleted, fireFinalized, fireStarted, onDeleted, onFinalized, register, unregister
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ToGerritRunListener

public ToGerritRunListener()
Default Constructor.

Method Detail

getInstance

public static ToGerritRunListener getInstance()
Returns the registered instance of this class from the list of all listeners.

Returns:
the instance.

onCompleted

public void onCompleted(hudson.model.AbstractBuild r,
                        hudson.model.TaskListener listener)
Overrides:
onCompleted in class hudson.model.listeners.RunListener<hudson.model.AbstractBuild>

onStarted

public void onStarted(hudson.model.AbstractBuild r,
                      hudson.model.TaskListener listener)
Overrides:
onStarted in class hudson.model.listeners.RunListener<hudson.model.AbstractBuild>

updateTriggerContexts

protected void updateTriggerContexts(hudson.model.AbstractBuild r,
                                     BuildMemory.PatchSetKey key)
Updates the TriggerContexts for all the GerritCauses in the build.

Parameters:
r - the build.
key - the memory key to update.
See Also:
BuildMemory.updateTriggerContext( com.sonyericsson.hudson.plugins.gerrit.trigger.gerritnotifier.model.BuildMemory.PatchSetKey, com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.GerritCause, hudson.model.AbstractBuild)

setThisBuild

protected void setThisBuild(hudson.model.AbstractBuild r)
Updates all GerritCauses TriggerContext.thisBuild in the build.

Parameters:
r - the build to update.

cleanUpGerritCauses

protected void cleanUpGerritCauses(GerritCause firstFound,
                                   hudson.model.AbstractBuild build)
Workaround for builds that are triggered by the same Gerrit cause but multiple times in the same quiet period.

Parameters:
firstFound - the cause first returned by Run.getCause(Class).
build - the build to clean up.

onTriggered

public void onTriggered(hudson.model.AbstractProject project,
                        PatchsetCreated event)
Called just before a build is scheduled by the trigger.

Parameters:
project - the project that will be built.
event - the event that caused the build to be scheduled.

onRetriggered

public void onRetriggered(hudson.model.AbstractProject project,
                          PatchsetCreated event,
                          List<hudson.model.AbstractBuild> otherBuilds)
Called just before a build is scheduled by the user to retrigger.

Parameters:
project - the project.
event - the event.
otherBuilds - the list of other builds in the previous context.

isBuilding

public boolean isBuilding(hudson.model.AbstractProject project,
                          PatchsetCreated event)
Checks the memory if the project is currently building the event.

Parameters:
project - the project.
event - the event.
Returns:
true if so.
See Also:
BuildMemory.isBuilding(PatchsetCreated, hudson.model.AbstractProject)

isBuilding

public boolean isBuilding(PatchsetCreated event)
Checks the memory if the event is building.

Parameters:
event - the event.
Returns:
true if so.
See Also:
BuildMemory.isBuilding(com.sonyericsson.hudson.plugins.gerrit.gerritevents.dto.events.PatchsetCreated)


Copyright © 2004-2011. All Rights Reserved.