Class EventListener
- java.lang.Object
-
- com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.EventListener
-
- All Implemented Interfaces:
com.sonymobile.tools.gerrit.gerritevents.GerritEventListener
public final class EventListener extends Object implements com.sonymobile.tools.gerrit.gerritevents.GerritEventListener
Event listener and scheduling forGerritTrigger
.- Author:
- Robert Sandell <rsandell@cloudbees.com>.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ParametersAction
createParameters(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event, Job project)
Creates a ParameterAction and fills it with the project's default parameters + the Standard Gerrit parameters.boolean
equals(Object obj)
Job
findJob()
Utility method for finding the Job instance referred to byjob
.void
gerritEvent(ManualPatchsetCreated event)
Called when a ManualPatchsetCreated event arrives.void
gerritEvent(com.sonymobile.tools.gerrit.gerritevents.dto.events.CommentAdded event)
Called when a CommentAdded event arrives.void
gerritEvent(com.sonymobile.tools.gerrit.gerritevents.dto.GerritEvent event)
String
getJob()
TheAbstractItem.getFullName()
this listener is for.GerritTrigger
getTrigger()
Utility method for finding theGerritTrigger
instance injob
.int
hashCode()
protected void
schedule(GerritTrigger t, GerritCause cause, com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event)
Schedules a build with parameters from the event.protected void
schedule(GerritTrigger t, GerritCause cause, com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event, Job project)
Schedules a build with parameters from the event.protected Future
schedule(Job theJob, int quitePeriod, GerritCause cause, BadgeAction badgeAction, ParametersAction parameters)
Schedules a build of a job.
-
-
-
Method Detail
-
getJob
public String getJob()
TheAbstractItem.getFullName()
this listener is for.- Returns:
- the fullName of the Job
-
gerritEvent
public void gerritEvent(com.sonymobile.tools.gerrit.gerritevents.dto.GerritEvent event)
- Specified by:
gerritEvent
in interfacecom.sonymobile.tools.gerrit.gerritevents.GerritEventListener
-
gerritEvent
public void gerritEvent(ManualPatchsetCreated event)
Called when a ManualPatchsetCreated event arrives.- Parameters:
event
- the event
-
gerritEvent
public void gerritEvent(com.sonymobile.tools.gerrit.gerritevents.dto.events.CommentAdded event)
Called when a CommentAdded event arrives.- Parameters:
event
- the event.
-
schedule
protected void schedule(GerritTrigger t, GerritCause cause, com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event)
Schedules a build with parameters from the event. Withjob
as the project to build.- Parameters:
t
- the trigger configcause
- the cause of the build.event
- the event.
-
schedule
protected void schedule(GerritTrigger t, GerritCause cause, com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event, Job project)
Schedules a build with parameters from the event.- Parameters:
t
- the trigger configcause
- the cause of the build.event
- the event.project
- the project to build.
-
schedule
protected Future schedule(Job theJob, int quitePeriod, GerritCause cause, BadgeAction badgeAction, ParametersAction parameters)
Schedules a build of a job.Added here to facilitate unit testing.
- Parameters:
theJob
- The job.quitePeriod
- Quite period.cause
- Build cause.badgeAction
- build badge action.parameters
- Build parameters.- Returns:
- Scheduled build future.
-
createParameters
protected ParametersAction createParameters(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event, Job project)
Creates a ParameterAction and fills it with the project's default parameters + the Standard Gerrit parameters. If running on a core version that let's us specify safeParameters for the ParameterAction the Gerrit specific parameters will be specified in the safeParameters list in addition to anything the admin might have set. A warning will be printed to the log if that is not possible but SECURITY-170 appears to be in effect.- Parameters:
event
- the event.project
- the project.- Returns:
- the ParameterAction.
-
getTrigger
@CheckForNull @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public GerritTrigger getTrigger()
Utility method for finding theGerritTrigger
instance injob
.- Returns:
- the trigger or null if job is gone or doesn't have a trigger.
-
findJob
@CheckForNull @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public Job findJob()
Utility method for finding the Job instance referred to byjob
.- Returns:
- the job unless environment doesn't allow it.
-
-