Class 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 for GerritTrigger.
    Author:
    Robert Sandell <rsandell@cloudbees.com>.
    • Method Detail

      • gerritEvent

        public void gerritEvent​(com.sonymobile.tools.gerrit.gerritevents.dto.GerritEvent event)
        Specified by:
        gerritEvent in interface com.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. With job as the project to build.
        Parameters:
        t - the trigger config
        cause - 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 config
        cause - 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 the GerritTrigger instance in job.
        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 by job.
        Returns:
        the job unless environment doesn't allow it.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object