Add support for Bitbucket Server webhook format

Currently you cannot setup a webhook with Bitbucket Server, even though you have support for Bitbucket.org, which creates an issue when trying to get builds to trigger after a push to a repository.

_Original request: Issues · bitrise-io/bitrise.io · GitHub

__Adding support to Bitbucket Server can be contributed to our open source Webhook processor: https://github.com/bitrise-io/bitrise-webhooks__

Once added (and accepted) there, it will just work.
If anyone have the time to implement it, we’d be glad to review & merge it, the README of the repository should cover every step required for developing the change, and you can even run your own version of the webhook server.

Right now we don’t have access to a Bitbucket Server instance, but if anyone can help us, either by letting us use one or to test a couple of things with us, we can also schedule to work on this.

Has anyone found out how to use Bitbucket server Hook to call into Bitrise?

1 Like

Hi @jdeitchler !

So, not supported right now, but can be contributed by anyone, following the README here: GitHub - bitrise-io/bitrise-webhooks: Bitrise Webhooks processor

We’d be happy to help too, if you have a question during the contribution :wink:

It seems the recent Bitbucket Server v5.4 added support for the Bitbucket V2 webhook support, the one we support for Bitbucket.org, but there’s a minor difference:

If anyone has some time before we could work on that, PRs are welcome :wink:

Seems to be not yet working. Tried to setup webhooks with BitBucket Server but only get a code 400 response
{"error":"Failed to transform the webhook: Content-Type is not supported: application/json; charset=UTF-8"}
:frowning:

Two things @MartinStraub:

  1. Please make sure that you use the Bitbucket Server specific webhook endpoint, as Bitbucket Server has a completely different webhook format compared to bitbucket.org .
    • For Bitbucket Server you should use the /h/bitbucket-server/BITRISE-APP-SLUG/BITRISE-APP-API-TOKEN format, instead of the /h/bitbucket-v2/BITRISE-APP-SLUG/BITRISE-APP-API-TOKEN which is bitbucket.org specific (simply replace bitbucket-v2 with bitbucket-server).
    • You can find more info in the webhook handler (open source) server’s repo at: https://github.com/bitrise-io/bitrise-webhooks
  2. If you did not push any code yet, just registered the webhook in Bitbucket Server, then it might also be that Bitbucket Server just sent a “ping” webhook, which has once again a different format (see: https://github.com/bitrise-io/bitrise-webhooks/issues/72 ). If you registered the right endpoint (the /h/bitbucket-server one) try to push a code change, that should work! :wink:

I already figured this out, together with your support.

Problem was 1., using the wrong url. But unfortunately, when you select BitBucket from the apps -> code -> incoming webhooks dropdown, you get the BitBucket cloud url. It’s a bit confusing as the dropdown lacks a specific BitBucket Server option and also doesn’t say BitBucket.org or cloud or something do differentiate it from the Server.

1 Like

Definitely makes sense - we created an internal bug report for this & linked this thread for context :wink:

Hello @MartinStraub,

Thank you for the issue report again, the fix is now released, so you can select Bitbucket Server from the webhook list on the Code tab of the application:

Happy building :house: :wink:

1 Like

This topic was automatically closed after 14 days. New replies are no longer allowed.