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 inisApplicable(hudson.model.Job<?, ?>)
only if it can parse hooks with events contributed inevents()
Each time this plugin wants to get events list from subscribers it asks for applicable status- Since:
- 1.12.0
- Author:
- lanwen (Merkushev Kirill)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
-
Constructor Summary
Constructors Constructor Description GHEventsSubscriber()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static ExtensionList<GHEventsSubscriber>
all()
protected abstract Set<org.kohsuke.github.GHEvent>
events()
Should be not null.static com.google.common.base.Function<GHEventsSubscriber,Set<org.kohsuke.github.GHEvent>>
extractEvents()
Converts each subscriber to set of GHEventsprotected abstract boolean
isApplicable(Item item)
Should return true only if this subscriber interested inevents()
set for this project Don't call it directly, useisApplicableFor(hudson.model.Job<?, ?>)
static functionprotected boolean
isApplicable(Job<?,?> project)
Deprecated.overrideisApplicable(Item)
instead.static com.google.common.base.Predicate<GHEventsSubscriber>
isApplicableFor(Item item)
Helps to filter only GHEventsSubscribers that can return TRUE on given itemstatic com.google.common.base.Predicate<GHEventsSubscriber>
isApplicableFor(Job<?,?> project)
Deprecated.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 eventprotected void
onEvent(GHSubscriberEvent event)
This method called when root action receives webhook from GH and this extension is interested in such events (provided byevents()
method).protected void
onEvent(org.kohsuke.github.GHEvent event, String payload)
Deprecated.overrideonEvent(GHSubscriberEvent)
instead.static com.google.common.base.Function<GHEventsSubscriber,Void>
processEvent(GHSubscriberEvent event)
Function which callsonEvent(GHSubscriberEvent)
for every subscriber on applystatic com.google.common.base.Function<GHEventsSubscriber,Void>
processEvent(org.kohsuke.github.GHEvent event, String payload)
Deprecated.
-
-
-
Method Detail
-
isApplicable
@Deprecated protected boolean isApplicable(@Nullable Job<?,?> project)
Deprecated.overrideisApplicable(Item)
instead.Should return true only if this subscriber interested inevents()
set for this project Don't call it directly, useisApplicableFor(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 inevents()
set for this project Don't call it directly, useisApplicableFor(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 inonEvent(GHEvent, String)
Don't call it directly, useextractEvents()
orisInterestedIn(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.overrideonEvent(GHSubscriberEvent)
instead.This method called when root action receives webhook from GH and this extension is interested in such events (provided byevents()
method). By default do nothing and can be overridden to implement any parse logic Don't call it directly, useprocessEvent(GHSubscriberEvent)
static function- Parameters:
event
- gh-event (as of PUSH, ISSUE...). One of returned byevents()
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 byevents()
method). By default do nothing and can be overridden to implement any parse logic Don't call it directly, useprocessEvent(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:
isApplicable(hudson.model.Job<?, ?>)
-
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:
isApplicable(hudson.model.Job<?, ?>)
-
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 ofevents()
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)
Deprecated.Function which callsonEvent(GHSubscriberEvent)
for every subscriber on apply- Parameters:
event
- from hook. Applied only with event fromevents()
setpayload
- 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 callsonEvent(GHSubscriberEvent)
for every subscriber on apply- Parameters:
event
- the event- Returns:
- function to process
GHEventsSubscriber
list. Returns null on apply. - Since:
- 1.26.0
-
-