Class GHEventsSubscriber

java.lang.Object
org.jenkinsci.plugins.github.extension.GHEventsSubscriber
All Implemented Interfaces:
ExtensionPoint
Direct Known Subclasses:
DefaultPushGHEventSubscriber, PingGHEventSubscriber

public abstract class GHEventsSubscriber extends Object implements ExtensionPoint
Extension point to subscribe events from GH, which plugin interested in. This point should return true in isApplicable(hudson.model.Job<?, ?>) only if it can parse hooks with events contributed in events() Each time this plugin wants to get events list from subscribers it asks for applicable status
Since:
1.12.0
Author:
lanwen (Merkushev Kirill)
  • Constructor Details

    • GHEventsSubscriber

      public GHEventsSubscriber()
  • Method Details

    • isApplicable

      @Deprecated protected boolean isApplicable(@Nullable Job<?,?> project)
      Deprecated.
      override isApplicable(Item) instead.
      Should return true only if this subscriber interested in events() set for this project Don't call it directly, use isApplicableFor(hudson.model.Job<?, ?>) static function
      Parameters:
      project - to check
      Returns:
      true to provide events to register and subscribe for this project
    • isApplicable

      protected abstract boolean isApplicable(@Nullable Item item)
      Should return true only if this subscriber interested in events() set for this project Don't call it directly, use isApplicableFor(hudson.model.Job<?, ?>) static function
      Parameters:
      item - to check
      Returns:
      true to provide events to register and subscribe for this item
      Since:
      1.25.0
    • events

      protected abstract Set<org.kohsuke.github.GHEvent> events()
      Should be not null. Should return only events which this extension can parse in onEvent(GHEvent, String) Don't call it directly, use extractEvents() or isInterestedIn(GHEvent) static functions
      Returns:
      immutable set of events this subscriber wants to register and then subscribe to.
    • onEvent

      @Deprecated protected void onEvent(org.kohsuke.github.GHEvent event, String payload)
      Deprecated.
      override onEvent(GHSubscriberEvent) instead.
      This method called when root action receives webhook from GH and this extension is interested in such events (provided by events() method). By default do nothing and can be overridden to implement any parse logic Don't call it directly, use processEvent(GHSubscriberEvent) static function
      Parameters:
      event - gh-event (as of PUSH, ISSUE...). One of returned by events() method. Never null.
      payload - payload of gh-event. Never blank. Can be parsed with help of GitHub#parseEventPayload
    • onEvent

      protected void onEvent(GHSubscriberEvent event)
      This method called when root action receives webhook from GH and this extension is interested in such events (provided by events() method). By default do nothing and can be overridden to implement any parse logic Don't call it directly, use processEvent(GHSubscriberEvent) static function
      Parameters:
      event - the event.
      Since:
      1.26.0
    • all

      public static ExtensionList<GHEventsSubscriber> all()
      Returns:
      All subscriber extensions
    • extractEvents

      public static com.google.common.base.Function<GHEventsSubscriber,Set<org.kohsuke.github.GHEvent>> extractEvents()
      Converts each subscriber to set of GHEvents
      Returns:
      converter to use in iterable manipulations
    • isApplicableFor

      @Deprecated public static com.google.common.base.Predicate<GHEventsSubscriber> isApplicableFor(Job<?,?> project)
      Deprecated.
      Helps to filter only GHEventsSubscribers that can return TRUE on given project
      Parameters:
      project - to check every GHEventsSubscriber for being applicable
      Returns:
      predicate to use in iterable filtering
      See Also:
    • isApplicableFor

      public static com.google.common.base.Predicate<GHEventsSubscriber> isApplicableFor(Item item)
      Helps to filter only GHEventsSubscribers that can return TRUE on given item
      Parameters:
      item - to check every GHEventsSubscriber for being applicable
      Returns:
      predicate to use in iterable filtering
      Since:
      1.25.0
      See Also:
    • isInterestedIn

      public static com.google.common.base.Predicate<GHEventsSubscriber> isInterestedIn(org.kohsuke.github.GHEvent event)
      Predicate which returns true on apply if current subscriber is interested in event
      Parameters:
      event - should be one of events() set to return true on apply
      Returns:
      predicate to match against GHEventsSubscriber
    • processEvent

      @Deprecated public static com.google.common.base.Function<GHEventsSubscriber,Void> processEvent(org.kohsuke.github.GHEvent event, String payload)
      Function which calls onEvent(GHSubscriberEvent) for every subscriber on apply
      Parameters:
      event - from hook. Applied only with event from events() set
      payload - string content of hook from GH. Never blank
      Returns:
      function to process GHEventsSubscriber list. Returns null on apply.
    • processEvent

      public static com.google.common.base.Function<GHEventsSubscriber,Void> processEvent(GHSubscriberEvent event)
      Function which calls onEvent(GHSubscriberEvent) for every subscriber on apply
      Parameters:
      event - the event
      Returns:
      function to process GHEventsSubscriber list. Returns null on apply.
      Since:
      1.26.0