Class GHEventsSubscriber
java.lang.Object
org.jenkinsci.plugins.github.extension.GHEventsSubscriber
- All Implemented Interfaces:
ExtensionPoint
- Direct Known Subclasses:
DefaultPushGHEventSubscriber
,PingGHEventSubscriber
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)
-
Nested Class Summary
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic 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>> 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.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
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.
-
Constructor Details
-
GHEventsSubscriber
public GHEventsSubscriber()
-
-
Method Details
-
isApplicable
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
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
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.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
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
- 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
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 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
-
isApplicable(Item)
instead.