Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using TeamCity with BitBucket

I am currently setting up a TeamCity build server that will pull source code from our git repositories, which are hosting on Bitbucket. I am doing this for a repositories that are setup as part of a team on Bitbucket (not my personal account).

What I am running into is that the URL paths seem to be custom for each user. For example, my paths look like:

https://[email protected]/TeamName/RepoName.git

If I were to leave the company, this would be a nightmare to update for 40+ builds.

I have considered creating a service account on bitbucket for the build server to use, but this will take up one of our users (we only have a 10-user license).

Is creating a separate account the recommended approach, or are there better options?

like image 406
Phil Sandler Avatar asked Nov 01 '13 15:11

Phil Sandler


People also ask

How do I use TeamCity with bitbucket?

Link Bitbucket with TeamCityClick on your avatar in the header and then on Manage account. Choose the TeamCity tab in the navigation bar, and add the token! After you've linked your TeamCity and Bitbucket accounts, you'll need to edit your build configuration in TeamCity and add Commit Status Publisher to it.


2 Answers

You should use a deployment key. It gives read-only access to both private and public repositories. Check the documentation at https://confluence.atlassian.com/display/BITBUCKET/Use+deployment+keys

like image 182
Antao Almada Avatar answered Sep 19 '22 21:09

Antao Almada


Creating a separate account is an acceptable approach if you want to do more on TeamCity side than just pull code for builds (for example, labeling builds, etc.). If you use a separate account for your TeamCity you could use both user/password authentication or SSH key authentication.

In the repository URL path you can safely remove the "MyUserName@" part which would make all the repository URLs uniformed regardless of how you access them. Moreover you could parameterize the user name and password in the TeamCity configuration so they can be overridden when someone wants to run a custom build.

As far as I am concerned there is no "recommended approach" for TeamCity since TeamCity is Git flavor agnostic. But Atlassian suggests to use SSH key when integrating with Bamboo. I am using a dedicated account for as long as I have one in the license since it makes management and debugging much easier.

like image 45
Alex T. Avatar answered Sep 19 '22 21:09

Alex T.