Interface BitbucketWebhookProcessor
- All Superinterfaces:
ExtensionPoint
- All Known Implementing Classes:
AbstractWebhookProcessor
,CloudPullRequestWebhookProcessor
,CloudPushWebhookProcessor
,PluginPullRequestWebhookProcessor
,PluginPushWebhookProcessor
,ServerPingWebhookProcessor
,ServerPullRequestWebhookProcessor
,ServerPushWebhookProcessor
@Restricted(org.kohsuke.accmod.restrictions.Beta.class)
public interface BitbucketWebhookProcessor
extends ExtensionPoint
Implementations of this extension point must provide new behaviours to
accommodate custom event payloads from webhooks sent from Bitbucket Cloud,
Bitbucket Data Center, or installed plugins.
There cannot be multiple processors processing the same incoming webhook for a specific event installed on the system, meaning the processor must fit to the incoming request as much as possible or the hook will be rejected in case of multiple matches.
- Since:
- 937.0.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionbuildHookContext
(jakarta.servlet.http.HttpServletRequest request) Returns a context for a given request used when process the payload.boolean
canHandle
(Map<String, String> headers, org.apache.commons.collections4.MultiValuedMap<String, String> parameters) Called by first for this processor that must respond if is able to handle this specific requestgetEventType
(Map<String, String> headers, org.apache.commons.collections4.MultiValuedMap<String, String> parameters) Extracts the event type that represent the payload in the request.getServerURL
(Map<String, String> headers, org.apache.commons.collections4.MultiValuedMap<String, String> parameters) Extracts the server URL from where this request coming from, the URL must match one of the configuredBitbucketEndpoint
s.default void
notifyEvent
(jenkins.scm.api.SCMHeadEvent<?> event, int delaySeconds) Implementations have to call this method when want propagate anSCMHeadEvent
to the scm-api.void
See Event Payloads for more information about the payload parameter format.default boolean
Settings that will trigger a re-index of the multibranch project/organization folder when the request does not ship any source changes.void
verifyPayload
(Map<String, String> headers, String payload, BitbucketEndpoint endpoint) The implementation must verify if the incoming request is secured or not eventually gather some settings from the givenBitbucketEndpoint
configuration.
-
Field Details
-
SCAN_ON_EMPTY_CHANGES_PROPERTY_NAME
- See Also:
-
-
Method Details
-
canHandle
boolean canHandle(@NonNull Map<String, String> headers, @NonNull org.apache.commons.collections4.MultiValuedMap<String, String> parameters) Called by first for this processor that must respond if is able to handle this specific request- Parameters:
headers
- requestparameters
- request- Returns:
true
if this processor is able to handle this hook request,false
otherwise.
-
getServerURL
@NonNull String getServerURL(@NonNull Map<String, String> headers, @NonNull org.apache.commons.collections4.MultiValuedMap<String, String> parameters) Extracts the server URL from where this request coming from, the URL must match one of the configuredBitbucketEndpoint
s.- Parameters:
headers
- requestparameters
- request- Returns:
- the URL of the server from where this request has been sent.
-
getEventType
@NonNull String getEventType(Map<String, String> headers, org.apache.commons.collections4.MultiValuedMap<String, String> parameters) Extracts the event type that represent the payload in the request.- Parameters:
headers
- requestparameters
- request- Returns:
- the event type key.
-
buildHookContext
@NonNull default Map<String,Object> buildHookContext(@NonNull jakarta.servlet.http.HttpServletRequest request) Returns a context for a given request used when process the payload.- Parameters:
request
- hook- Returns:
- a map of information extracted by the given request to be used in
the
process(String, String, Map, BitbucketEndpoint)
method.
-
verifyPayload
void verifyPayload(@NonNull Map<String, String> headers, @NonNull String payload, @NonNull BitbucketEndpoint endpoint) throws BitbucketWebhookProcessorExceptionThe implementation must verify if the incoming request is secured or not eventually gather some settings from the givenBitbucketEndpoint
configuration.- Parameters:
headers
- requestpayload
- requestendpoint
- configured for the givengetServerURL(Map, MultiValuedMap)
- Throws:
BitbucketWebhookProcessorException
- when signature verification fails
-
reindexOnEmptyChanges
default boolean reindexOnEmptyChanges()Settings that will trigger a re-index of the multibranch project/organization folder when the request does not ship any source changes.- Returns:
- if should perform a reindex of the project or not.
-
process
void process(@NonNull String eventType, @NonNull String payload, @NonNull Map<String, Object> context, @NonNull BitbucketEndpoint endpoint) See Event Payloads for more information about the payload parameter format.- Parameters:
eventType
- the type of hook event.payload
- the hook payloadcontext
- build from incoming requestendpoint
- configured in the Jenkins global page
-
notifyEvent
default void notifyEvent(jenkins.scm.api.SCMHeadEvent<?> event, int delaySeconds) Implementations have to call this method when want propagate anSCMHeadEvent
to the scm-api.- Parameters:
event
- the to firedelaySeconds
- a delay in seconds to wait before propagate the event. If the given value is less than 0 than default will be used.
-