Automatic hook management updates unrelated webhook on Bitbucket Server

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major
    • None
    • Environment:
      Atlassian Bitbucket v9.4.16
      Jenkins 2.528.3
      Bitbucket Branch Source 937.2.2
    • 937.2.5

      There is a rather severe issue in the webhook management in that it considers webhooks as update candidates that belong to totally different hook plugins like https://plugins.jenkins.io/generic-webhook-trigger/

      Webhooks for the generic-webhook-trigger Plugin have (obviously) the same Jenkins root URL as the webhooks this bitbucket-plugin is creating/managing.
      The difference is what comes after the root part: for this plugin it's "bitbucket-scmsource-hook" but for the generic-webhook-trigger it's "generic-webhook-trigger".
      URL examples:

      Problem is that this very important difference is not respected by the hook selection logic in ServerWebhookManager as it only checks the root part (with startsWith).

      This means that the first webhook with the same root url as configured for this plugin will be updated to point to "bitbucket-scmsource-hook" even though the webhook might be totally unrelated.
      This can break all sorts of things.

      Steps to reproduce the issue

      1. a single webhook exists with an URL like https://mydomain.example.org/jenkins/generic-webhook-trigger/invoke?token=secret (notice the "generic-webhook-trigger" part)
      2. "Server URL" in Bitbucket Server configuration (on Jenkins "System" config page) is: https://mydomain.example.org/jenkins
      3. automatic webhook management is activated with "Native Data Center"

      Actual Behaviour

      Instead of creating a new webhook, the existing webhooks URL is manipulated to e.g. https://mydomain.example.org/jenkins/bitbucket-scmsource-hook/notify?server_url=https%3A%2F%2Fbitbucket.example.org and the hook events are changed too (notice especially the switch form "generic-webhook-trigger" to "bitbucket-scmsource-hook")

            Assignee:
            Nikolas Falco
            Reporter:
            Falko Modler
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: