3

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)

Andrea Franchini
  • 548
  • 4
  • 14
  • Where do you see that Bitbucket Cloud webhooks are only GET? – Jim Redmond Jan 02 '19 at 18:21
  • Settings => webhooks => add webhook => i don't see where set the method. So i've searched and found that a repository administrator can add a "POST service webhook" ([doc here](https://confluence.atlassian.com/bitbucketserver/post-service-webhook-for-bitbucket-server-776640367.html)) but the body is fixed. Teamcity side is needed a specific body format. – Andrea Franchini Jan 04 '19 at 09:04
  • Where is that documentation? Please add a link. – Jim Redmond Jan 04 '19 at 18:27
  • [Bitbucket Manage webhooks](https://confluence.atlassian.com/bitbucket/manage-webhooks-735643732.html) - [Bitbucket Post service webhook](https://confluence.atlassian.com/bitbucketserver/post-service-webhook-for-bitbucket-server-776640367.html) - [TeamCity REST API](https://confluence.jetbrains.com/display/TCD18/REST+API#RESTAPI-TriggeringaBuild) - [TeamCity Deprecated API version](https://confluence.jetbrains.com/display/TCD18/Accessing+Server+by+HTTP#AccessingServerbyHTTP-TriggeringaCustomBuild) – Andrea Franchini Jan 07 '19 at 08:33
  • Your first link only uses the strings "get" and "post" in links and in regular English phrases; it does not mention any specific HTTP methods. Your second link is for Bitbucket Server, the on-premise version. And your third and fourth links don't mention Bitbucket Cloud. Where do you see that Bitbucket Cloud webhooks are only GET, and how would any webhook function like that? – Jim Redmond Jan 07 '19 at 19:14
  • Ok, I think that here there is some misunderstanding. Let's reformulate the question like: "How can I set up a Bitbucket Cloud webhook (let's suppose that it will be triggered on each PR creation) in order to make a POST request (let's suppose to Teamcity remote server) with a custom body?" – Andrea Franchini Jan 17 '19 at 11:05

1 Answers1

0

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:

Andrea Franchini
  • 548
  • 4
  • 14