Class GitHubDuplicateEventsMonitor.DuplicateEventsSubscriber
java.lang.Object
org.jenkinsci.plugins.github.extension.GHEventsSubscriber
org.jenkinsci.plugins.github.admin.GitHubDuplicateEventsMonitor.DuplicateEventsSubscriber
- All Implemented Interfaces:
ExtensionPoint
- Enclosing class:
- GitHubDuplicateEventsMonitor
@Extension
public static final class GitHubDuplicateEventsMonitor.DuplicateEventsSubscriber
extends GHEventsSubscriber
Tracks duplicate
GHEvent triggering actions in Jenkins.
Events are tracked for 10 minutes, with the last detected duplicate reference retained for up to 24 hours
(see isDuplicateEventSeen()).
Duplicates are stored in-memory only, so a controller restart clears all entries as if none existed. Persistent storage is omitted for simplicity, since webhook misconfigurations would likely cause new duplicates.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordNested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Set<org.kohsuke.github.GHEvent>events()Should be not null.protected booleanisApplicable(Item item) This subscriber is not applicable to any itembooleanChecks if a duplicate event was recorded in the past 24 hours.protected voidonEvent(GHSubscriberEvent event) This method called when root action receives webhook from GH and this extension is interested in such events (provided byGHEventsSubscriber.events()method).Methods inherited from class org.jenkinsci.plugins.github.extension.GHEventsSubscriber
all, extractEvents, isApplicable, isApplicableFor, isApplicableFor, isInterestedIn, onEvent, processEvent, processEvent
-
Constructor Details
-
DuplicateEventsSubscriber
public DuplicateEventsSubscriber()
-
-
Method Details
-
isApplicable
This subscriber is not applicable to any item- Specified by:
isApplicablein classGHEventsSubscriber- Parameters:
item- ignored- Returns:
- always false
-
events
Should be not null. Should return only events which this extension can parse inGHEventsSubscriber.onEvent(GHEvent, String)Don't call it directly, useGHEventsSubscriber.extractEvents()orGHEventsSubscriber.isInterestedIn(GHEvent)static functionsSubscribes to events that trigger actions in Jenkins, such as repository scans or builds.
The
GHEventenum defines about 63 events, but not all are relevant to Jenkins. Tracking unnecessary events increases memory usage, and they occur more frequently than those triggering any work.- Specified by:
eventsin classGHEventsSubscriber- Returns:
- immutable set of events this subscriber wants to register and then subscribe to.
-
onEvent
Description copied from class:GHEventsSubscriberThis method called when root action receives webhook from GH and this extension is interested in such events (provided byGHEventsSubscriber.events()method). By default do nothing and can be overridden to implement any parse logic Don't call it directly, useGHEventsSubscriber.processEvent(GHSubscriberEvent)static function- Overrides:
onEventin classGHEventsSubscriber- Parameters:
event- the event.
-
isDuplicateEventSeen
public boolean isDuplicateEventSeen()Checks if a duplicate event was recorded in the past 24 hours.Events are not stored for 24 hours—only the most recent duplicate is checked within this timeframe.
- Returns:
trueif a duplicate was seen in the last 24 hours,falseotherwise.
-
getLastDuplicate
public GitHubDuplicateEventsMonitor.DuplicateEventsSubscriber.TrackedDuplicateEvent getLastDuplicate()
-