Bitbucket Server (formerly known as Stash) is a solution for centralized development management that allows you to manage your repositories, including without opening access to them from outside the organization. Bitbucket allows you to simplify storage of repositories with source codes on your server and provides ease of access to repositories for all members of your team.
In the IT world, it is known that Bitbucket can be integrated with other products and platforms into a single ecosystem that makes the development process comprehensive and convenient. Most often, Bitbucket integrates with
JIRA . However, the search for and localization of problems is not the only task that a typical development process faces every day, and even several times a day. A more important task is to preserve the integrity of the project in the process of making additions and corrections to the code. For these tasks, you can use the CI server, which, among other things, allows you to create project assemblies and run a series of tests to automatically verify functionality.
')
Bitbucket out of the box offers integration with
Atlassian's related solution,
Bamboo . But, in addition to Bamboo, there are other CI-solutions that are also quite popular -
TeamCity and
Jenkins . In our post we will outline the specifics of the integration of Bitbucket and TeamCity.
REST API as an integration point with Bitbucket
Since Bitbucket acquired the REST API (in fact, it was always with Stash and expanded as the Stash / Bitbucket Server functionality developed - note of the translator), it became much easier for him to work and build solutions for each case study. Currently, there are several add-ons for integrating Bitbucket with CI-systems and obtaining information on the status of assemblies. By examining commits in the repository, you can simultaneously see the build status and easily go to TeamCity to study the problems encountered when building a particular commit, or simply download the latest version of the application for the client.
Tools for the integration of TeamCity and Bitbucket
On the Internet, you can find two TeamCity plugins that can be used to integrate with Bitbucket.
Commit Status Publisher was released directly by
JetBrains , the other -
TeamCity Stash Integration - was developed by
mendhak . Both have proven to work as a means of integrating Teamcity and Bitbucket. Let's take a look at each of them and look for their pros and cons.
Installing plugins in Teamcity
Installing plug-ins in TeamCity is quite simple and follows the
documentation . We load zip-archives with plug-ins through the administrative console of Teamcity, restart Teamcity. Plugins are available and ready to help you get the information you need.

Jet Status Publisher from JetBrains
First of all, let's introduce the “native” plugin from the developer of the TeamCity itself, since the integration tools from the “developer” are usually convenient, thoughtful and functional. Configure the assembly to transfer the status of the assembly to Bitbucket. To do this, add the Build Feature with the type Commit status publisher (this type becomes available after installing the plugin from JetBrains). Finish connecting to Bitbucket.

After the setup is complete, run the build and verify that Bitbucket received the data from TeamCity.

Clicking on the assembly icon opens a window containing information about the project, configuration, and assembly number. The number of passed and ignored tests is also displayed.

When viewing the details of the pull request, you can also open the form with the assembly information.

Teamcity Stash (Bitbucket) integration from mendhak
Plugin is configured similarly to the solution from JetBrains. After installation, a build feature appears with the name Report build status to Atlassian Bitbucket. Unlike the JetBrains addon, more settings appear. You can, for example, mark a canceled assembly in Bitbucket as unsuccessful. Or do not show the status of all builds in Bitbucket, leaving only the status of the last build for each commit.

After the code commit, you can see the assemblies that depend on this commit and their status.

Which plugin to choose?
It should be noted that they are very similar to each other. Both use the Bitbucket REST API to update build statuses. Both are very easy to install and configure. On the side of the “native” plug-in from JetBrains is support for new versions of TeamCity (in TeamCity 10 this plug-in will be built out of the box - translator's note), fast release of new versions and support from a team of world-famous developers. On the side of TeamCity Stash (Bitbucket) Integration - a bit more functionality and detailed instructions on how to configure the plugin. The choice of add-on is yours and depends on your requirements and wishes.