Atlassian has always focused heavily on providing API's for their tools, to allow integration by third parties. One way they do this is by keeping their tools open to integration with other tools. Integrations can open up a whole new world of automation with Atlassian tools. Some actions that can be achieved by integrating Atlassian products with other tools are creating an issue from a failed build, reporting an outage on HipChat and much more. 

Atlassian tools are extremely able to be integrated and their out of the box usability can be extended by other top performing DevOps tools. In this instance, we will explain the integration points between JetBrain's TeamCity and Atlassian's JIRA and Bitbucket. 


TeamCity is a build management and continuous integration server from JetBrains, that is completely Java basedTeamCity can build, check and run automated tests on a server, before committing any changes. Ensuring that your code base is clean, at all times. By constantly tracking different stages of your build, TeamCity can build reports on that data and have it ready for you to view, at anytime. This allows TeamCity to instantly notify you about any build problems or large changes that have been made. 

Untitled Diagram.jpg

TeamCity automatically contacts and assigns an agent to work on a new build, when it is shown that a new build is needed. The process thereafter is simple and for the following example, we will layout the process for a Maven build. The agent simply check's the TeamCity repository, performs the build and keeps track of the artifact. 

The default configuration in TeamCity is to schedule a build automatically. However, when you configure TeamCity with Bitbucket, you can schedule the build to start on each push. TeamCity also has the ability to communicate with JIRA. Once integrated, TeamCity creates issues for failed builds and JIRA then pulls information needed for the ticket, about each build. In this blog, we will see how to configure TeamCity with JIRA and Bitbucket. 

Learn more about TeamCity

Setting Up a Bitbucket Integration

  1. Create a Project in TeamCity. 
    Capture 2017-03-01 at 18.08.13.png

  2. Click on Repository URL to begin the integration between Bitbucket and TeamCity. 
    Capture 2017-03-01 at 18.10.32.png

  3. Copy the repository URL from your Bitbucket instance. 
    Capture 2017-03-01 at 18.11.51.png

  4. Paste the URL into the Project form and fill out the rest of the requested details.
    Capture 2017-03-01 at 18.12.52.png

  5. Then click Proceed.
    Capture 2017-03-01 at 18.13.36.png

  6. Once saved, the TeamCity Project Build settings will pop up. Select Maven (or any other Build Setup) and click Use Selected.
    Capture 2017-03-01 at 18.14.14.png

  7. Click on Edit in the Build Steps settings. 
    Capture 2017-03-01 at 18.15.23.png

  8. Fill out Package in the Goals section and click Save.
    Capture 2017-03-01 at 18.17.45.png

  9. Add your artifact path link and click Save.
    Capture 2017-03-01 at 18.24.33.png

  10. In the Version Control Settings tab, click Edit.
    Capture 2017-03-02 at 14.25.23.png

  11. Add the branches from you Bitbucket instance and click Save.
    Capture 2017-03-02 at 14.24.35.png  

  12. Click on the Triggers tab and click Add a new trigger.
    Capture 2017-03-02 at 14.26.25.png

  13. From the dropdown menu, click on Branch Remote Run Trigger and add your GIT Pattern of Branches to that you want to track.
    Capture 2017-03-02 at 14.27.03.png  

  14. Once all of those steps are complete, now it is time to link TeamCity to JIRA. Click on the Issue Trackers tab and then click on Create new connection.
    Capture 2017-03-01 at 18.25.45.png

  15. Fill in the details from your JIRA instance and click Save.
    Capture 2017-03-01 at 18.27.04.png

  16. Now you can test your configuration. Go back to your TeamCity homepage and click on run to perform a test build. 
    Capture 2017-03-01 at 18.28.12.png

  17. If everything was configured correctly, your build will pass! Congrats, your TeamCity instance is integrated with your JIRA and Bitbucket instances!
    Capture 2017-03-01 at 18.30.40.png

At this stage TeamCity is able to communicate with Bitbucket so that a build is made periodically. However, in order to get the functionality to make a build on every repository change, we need to configure a hook in Bitbucket.

Configuring a hook in Bitbucket to communicate with TeamCity

  1. Install the following add-on into your Bitbucket instance.

  2. Go to your Bitbucket Project Repository and click on Settings.
    Capture 2017-03-01 at 18.33.18.png

  3. Click on the Hooks tab.
    Capture 2017-03-01 at 18.34.03.png

  4. Click Enable located next to the Post Receive- TeamCity Trigger.
    Capture 2017-03-01 at 18.34.46.png

  5. Add the Connection details from your TeamCity instance.
    Capture 2017-03-01 at 18.35.49.png

  6. Write the values under the Build Configuration tab, to enable branch based tracking and click Save.
    Capture 2017-03-01 at 18.37.06.png

  7. Your configuration is now complete! The final step is to make a change in your code in order to see the build trigger.
    Screenshot from 2017-03-20 18:39:57.png

  8. Then commit and push these changes to Bitbucket. 

    $ git add .
    $ git commit -m "Changes for TeamCity Testing"
    $ git push origin master
  9. In TeamCity, you will now be able see the build in action.
    Capture 2017-03-01 at 18.43.20.png

  10. You can also see that the build has passed. Capture 2017-03-01 at 18.44.09.png

Integrating TeamCity with JIRA Software

  1. Install the following add-on into your JIRA instance.
  2. Go to the Application Page in JIRA and click on TeamCity Servers under the TeamCity Configuration list.
    Capture 2017-03-02 at 13.52.44.png

  3. Click on Add TeamCity Server.
    Capture 2017-03-02 at 13.54.55.png

  4. Fill in the details from your TeamCity instance into the form.
    Capture 2017-03-02 at 13.54.19.png

  5. In your JIRA project, click on the TeamCity tab.
    Capture 2017-03-02 at 13.56.37.png

  6. You should see your builds and their statuses. 
    Capture 2017-03-02 at 13.58.02.png

  7. Your TeamCity instance is now integrated with JIRA Software!


In this blog you saw how to integrate Atlassian's Bitbucket and JIRA Software with TeamCity. This integration allows us to verify our code quality by performing regular builds. By seeing the code while you are building and seeing the status of each in JIRA, software engineers are now able to focus more on the code they are writing. Instead of spending quality time building and verifying your code.