How to make a Bitbucket POST webhook to TeamCity?

Viewed 2243

I've already serched and struggled on this argument... without success.

Setup:

  • Bitbucket Cloud
  • Local TeamCity server and agents

The problem is the following: run build with webhooks and not with polling.

TeamCity side, for trig a build there are only two POST URL:

  • a deprecated one with parameters in the query string (note: docs says "HTTP GET" but when testing i've got "405 Only POST method is allowed for this request")
  • the "new" one with predefined parameters in the request body to define which build to run and other things

Bitbucket side:

  • i can't find how to specify wildcard/placeholder for URL/Body parameters as "actual branch"
  • there are little few plugins that can help, but they aren't available for cloud

Nice plugin: http-request-hook-for-bitbucket-server - it will solve our problem, performing a request with a wildcard to the deprecated Teamcity url... but isn't available for Bitbucket Cloud.

Any suggestions on how to make this works?

Thanks in advance.

EDIT: Let's recap the question like: "How can I set up a Bitbucket Cloud webhook in order to make a POST request with a custom body?"

EDIT2: Bitbucket cloud actually use the POST method (cleaned above)

1 Answers

The final solution adopted is to create a mincro HTTP server (50 line fastify app) that receive the Bitbucket Cloud Webhook (which actually came as POST but at this point doesn't matters), pick up the data of interest and calls the Teamcity API for enqueue a build.

Links:

Related