Class SCMHeadEvent<P>
- java.lang.Object
-
- jenkins.scm.api.SCMEvent<P>
-
- jenkins.scm.api.SCMHeadEvent<P>
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class jenkins.scm.api.SCMEvent
SCMEvent.Dispatcher<E extends SCMEvent<?>>, SCMEvent.EventQueueMetrics, SCMEvent.Type
-
-
Field Summary
-
Fields inherited from class jenkins.scm.api.SCMEvent
ORIGIN_UNKNOWN
-
-
Constructor Summary
Constructors Modifier Constructor Description SCMHeadEvent(SCMEvent.Type type, long timestamp, P payload)
Deprecated.SCMHeadEvent(SCMEvent.Type type, long timestamp, P payload, String origin)
SCMHeadEvent(SCMEvent.Type type, P payload)
Deprecated.SCMHeadEvent(SCMEvent.Type type, P payload, String origin)
protected
SCMHeadEvent(SCMHeadEvent<P> src)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description String
descriptionFor(SCM scm)
Return a description of the event in the context of the suppliedSCM
.String
descriptionFor(SCMNavigator navigator)
Return a description of the event in the context of the suppliedSCMNavigator
.String
descriptionFor(SCMSource source)
Return a description of the event in the context of the suppliedSCMSource
.<O extends SCMHeadObserver>
SCMHeadObserver.Wrapped<O>filter(SCMSource source, O delegate)
Wraps aSCMHeadObserver
such that the wrapped observer will only observeSCMHead
instances mentioned in this event.static void
fireLater(SCMHeadEvent<?> event, long delay, TimeUnit delayUnits)
Fires theSCMHeadEvent
to all registeredSCMEventListener
instances after the specified delay.static void
fireNow(SCMHeadEvent<?> event)
Fires theSCMHeadEvent
to all registeredSCMEventListener
instances.abstract String
getSourceName()
Returns the name of theSCMSource
, such as a repository name within an organization; may be used as anItem.getName()
.abstract Map<SCMHead,SCMRevision>
heads(SCMSource source)
abstract boolean
isMatch(SCM scm)
Tests if this event applies to the suppliedSCM
.abstract boolean
isMatch(SCMNavigator navigator)
Tests if this event applies to the suppliedSCMNavigator
.boolean
isMatch(SCMSource source)
Tests if this event applies to the suppliedSCMSource
.-
Methods inherited from class jenkins.scm.api.SCMEvent
asCauses, closeExecutorService, description, equals, executorService, getDate, getEventProcessingMetrics, getOrigin, getPayload, getTimestamp, getType, hashCode, originOf, toString
-
-
-
-
Constructor Detail
-
SCMHeadEvent
@Deprecated public SCMHeadEvent(@NonNull SCMEvent.Type type, long timestamp, @NonNull P payload)
Deprecated.
-
SCMHeadEvent
public SCMHeadEvent(@NonNull SCMEvent.Type type, long timestamp, @NonNull P payload, @CheckForNull String origin)
-
SCMHeadEvent
@Deprecated public SCMHeadEvent(@NonNull SCMEvent.Type type, @NonNull P payload)
Deprecated.
-
SCMHeadEvent
public SCMHeadEvent(@NonNull SCMEvent.Type type, @NonNull P payload, @CheckForNull String origin)
-
SCMHeadEvent
protected SCMHeadEvent(@NonNull SCMHeadEvent<P> src)
-
-
Method Detail
-
isMatch
public abstract boolean isMatch(@NonNull SCMNavigator navigator)
Tests if this event applies to the suppliedSCMNavigator
.- Parameters:
navigator
- theSCMNavigator
.- Returns:
true
if and only if this event concerns the suppliedSCMNavigator
.
-
descriptionFor
@CheckForNull public String descriptionFor(@NonNull SCMNavigator navigator)
Return a description of the event in the context of the suppliedSCMNavigator
.- Parameters:
navigator
- theSCMNavigator
, the navigator must beisMatch(SCMNavigator)
.- Returns:
- the description or
null
if no description can be provided. - Since:
- 2.1.1
-
getSourceName
@NonNull public abstract String getSourceName()
Returns the name of theSCMSource
, such as a repository name within an organization; may be used as anItem.getName()
. Must be the same as the name that would be passed toSCMSourceObserver.observe(String)
by anySCMNavigator
thatisMatch(SCMNavigator)
.NOTE: if and only if
isMatch(SCMNavigator)
always returnsfalse
then the value returned here does not matter and a dummy value can be returned instead.DO NOT TRUST THE RETURN VALUES. Data from events should only be used as a rumour that requires verification.
- Returns:
- the name of the
SCMSource
-
isMatch
public boolean isMatch(@NonNull SCMSource source)
Tests if this event applies to the suppliedSCMSource
.
-
descriptionFor
@CheckForNull public String descriptionFor(SCMSource source)
Return a description of the event in the context of the suppliedSCMSource
.- Parameters:
source
- theSCMSource
, the source must beisMatch(SCMSource)
.- Returns:
- the description or
null
if no description can be provided. - Since:
- 2.1.1
-
heads
@NonNull public abstract Map<SCMHead,SCMRevision> heads(@NonNull SCMSource source)
Returns theSCMHead
for the suppliedSCMSource
that this event corresponds to.DO NOT TRUST THE RETURN VALUES. Data from events should only be used as a rumour that requires verification.
- Parameters:
source
- theSCMSource
.- Returns:
- the
SCMHead
(and optionalSCMRevision
) that this event corresponds to when considered from the point of view of the suppliedSCMSource
. The map may be empty in the case where the event is not relevant to the suppliedSCMSource
-
isMatch
public abstract boolean isMatch(@NonNull SCM scm)
Tests if this event applies to the suppliedSCM
. Implementations that returntrue
will trigger polling for the matching jobs that have enabled theSCMTrigger
and have not disabled the post commit hooksSCMTrigger.isIgnorePostCommitHooks()
.NOTE: if you are implementing
SCMHeadEvent
and you already have a separate code path responsible for notifyingSCMTrigger
then you should either remove that code path or always returnfalse
from this method. The recommendation is to consolidate onSCMHeadEvent
based triggering as that minimizes the number of times the graph of all items needs to be traversed by event listeners.- Parameters:
scm
- theSCM
.- Returns:
true
if and only if this event concerns the suppliedSCM
.- See Also:
SCMTriggerListener
,SCMTrigger.isIgnorePostCommitHooks()
-
descriptionFor
@CheckForNull public String descriptionFor(SCM scm)
Return a description of the event in the context of the suppliedSCM
.- Parameters:
scm
- theSCM
, the scm must beisMatch(SCM)
.- Returns:
- the description or
null
if no description can be provided. - Since:
- 2.1.1
-
filter
public <O extends SCMHeadObserver> SCMHeadObserver.Wrapped<O> filter(@NonNull SCMSource source, O delegate)
Wraps aSCMHeadObserver
such that the wrapped observer will only observeSCMHead
instances mentioned in this event.- Type Parameters:
O
- the type of delegate.- Parameters:
source
- theSCMSource
.delegate
- the delegate.- Returns:
- the wrapped delegate.
-
fireNow
public static void fireNow(@NonNull SCMHeadEvent<?> event)
Fires theSCMHeadEvent
to all registeredSCMEventListener
instances.- Parameters:
event
- the event to fire.
-
fireLater
public static void fireLater(@NonNull SCMHeadEvent<?> event, long delay, TimeUnit delayUnits)
Fires theSCMHeadEvent
to all registeredSCMEventListener
instances after the specified delay.- Parameters:
event
- the event to fire.delay
- how long to wait before firing the event.delayUnits
- the units of time in which the delay is expressed.
-
-