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
  • Field Details

  • 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 - request
      parameters - 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 configured BitbucketEndpoints.
      Parameters:
      headers - request
      parameters - 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 - request
      parameters - 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 BitbucketWebhookProcessorException
      The implementation must verify if the incoming request is secured or not eventually gather some settings from the given BitbucketEndpoint configuration.
      Parameters:
      headers - request
      payload - request
      endpoint - configured for the given getServerURL(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 payload
      context - build from incoming request
      endpoint - 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 an SCMHeadEvent to the scm-api.
      Parameters:
      event - the to fire
      delaySeconds - a delay in seconds to wait before propagate the event. If the given value is less than 0 than default will be used.