buildkite / feedback

Got feedback? Please let us know!
https://buildkite.com
25 stars 24 forks source link

Add support for Bitbucket Server build status API #276

Open amasses opened 7 years ago

amasses commented 7 years ago

Currently we have a webtask that received the BK Webhook, and then transforms this into an API call into Bitbucket Server (we are on 5.2.1) to send build notifications.

If this could be handled by Buildkite that would make life much simpler :)

Docs for build notification API in Bitbucket Server: https://developer.atlassian.com/bitbucket/server/docs/latest/how-tos/updating-build-status-for-commits.html

Thanks! 👍

sj26 commented 6 years ago

This is awesome, and we'd love to do it, but it's going to require an overhaul of our Bitbucket Server integration without affecting our existing integrations with older versions which seems quite tricky. We'll take a look when we can.

sj26 commented 6 years ago

We've posted some issues upstream with Atlassian to give us enough details in their webhooks to make this happen:

amasses commented 6 years ago

Thanks! Do you know if the existing setup (using the hooks plugin) still works with updated versions of Bitbucket? Or does upgrading completely bork this?

exidy commented 6 years ago

@amasses the hooks plugin still works with BitBucket Server 5+, but only triggers on a simple push to a branch. No builds for PRs and no build statuses in BitBucket Server.

sj26 commented 6 years ago

The existing setup instructions which advise using Bitbucket Server Web Post Hooks Plugin still work, yes.

We've also added some tentative support for the new Bitbucket Server 5.4 webhooks, limited to building pushed branches, tags, and newly created pull requests. Notably support for pull request updates are currently lacking due to insufficient hooks, as mentioned earlier in this thread. You can create a webhook integration in your Bitbucket Server if you have at least version 5.4 and point it at your Buildkite pipeline's webhook url to try them out.

I've also discovered the Post Webhooks for Bitbucket plug-in which looks very promising and seems to mirror Bitbucket Cloud's webhooks, including code push, pull request created and updated. Will investigate this one when we can to see if we can add support for more comprehensive pull request building.

robodair commented 6 years ago

Is there any movement on this with latest Bitbucket Server? It seems like the information is there now in the webhooks, and pull request status can be inferred from build status on the tip commit.

sj26 commented 6 years ago

It's encouraging that they're working on webhooks! Sadly all they've added so far is details about pull request titles or branch targets changing, they still don't provide any commit details (author / message), or any event when new commits are added to an existing pull request (which is the important missing piece). I've already added a comment to the JIRA issues.

robodair commented 6 years ago

@sj26 Sorry if you've already seen the documentation I'm about to point out;

Using the repo:refs_changed event which gives you the commit hash(es) for the branch changed should allow Buildkite to build those tip commits.

Then, publishing build status at that commit using Updating build status for commits should let bitbucket server handle pull request status with Minimum successful builds merge check.

It's not as nice as publishing the result directly as a pull request status check and having pull request updates trigger builds, resulting in more builds being run, but it's a workable solution. Seems like writing a small service to do exactly this is what @amasses has done but would like it to be part of Buildkite directly. While I'd prefer the github-like pull request synchronized flow while also only building tip commits on master, this would be good enough.

So there's no plan for this to get first-class support?

pauldraper commented 5 years ago

I use https://github.com/rivethealth/buildkite-webhook-aws-terraform to make Buildkite publish to AWS SNS and then https://github.com/rivethealth/buildkite-bitbucket-aws-terraform to run AWS Lambda function to update Bitbucket.