Mendhak / Code

TeamCity to Bitbucket Status Reporter

This build feature sends build status updates from TeamCity to Bitbucket. You can then see build statuses against commits.

TeamCity - Stash integration. Plugin for TeamCity which updates Stash with build statuses

Why use this

Reporting build statuses to Bitbucket is a useful way of working with pull requests. Bitbucket allows you to restrict pull request approvals to a passing builds in addition to the usual approvers, so this can be used to gain some confidence with regards to the quality of a pull request.

Bitbucket screenshot

TeamCity 10: Recent releases of TeamCity now include a commit status publisher which works with Bitbucket, Github, Gitlab and Gerrit.

Install

Download the .zip file and place it in the <TeamCity data directory>/plugins folder, then restart TeamCity.

Set-up

Under your build steps, click on Add Build Feature. It will appear in the dropdown list.

Build Feature

Simply enter your Bitbucket server details and credentials to connect with. The plugin will now send build status updates to your Bitbucket server.

Configuration

How it works

This is a TeamCity Build Feature built using the TeamCity Open API.

It listens for build statuses and posts them to the Atlassian Bitbucket Build API.

License

GPL v2


Code setup

You will need IntelliJ IDEA as this project uses IDEA features to build artifacts.

You will also need to download and extract TeamCity which provides the required jars.

Open the project in Intellij IDEA, you should see a lot of unresolved references, this is normal.

Go to File | Settings | Path Variables and set the TeamCityDistribution variable, pointing it to your TeamCity location.

To build the project, click Build | Build Artifacts... and choose plugin-zip. The .zip is generated in /out/artifacts/plugin_zip.

Troubleshooting

If the plugin doesn’t seem to be working, you can find plugin messages in the teamcity-server.log file under your TeamCity installation. (Example: /TeamCity/logs/teamcity-server.log) This usually gives you a good idea of why a call may have failed.

You can also look at Bitbucket’s atlassian-bitbucket.log under BITBUCKET_HOME’s log folder (Example: /Bitbucket-Home/log/atlassian-bitbucket.log) file to see what it did with the HTTP request sent by the plugin. In the log file, search for POST /rest/build-status as a starting point.