Deveo supports feature branch workflows and setting up quality gates using approvals from teammates in addition to connecting any build tool to the workflow. The basic review and approval workflow using Git was described in an earlier released blog post. In addition, we wrote about setting up feature branch workflow integration with Jenkins continuous integration server and using Git feature branches.
In this blog post, we are going through the steps to take another commonly used continuous integration server called TeamCity as part of our feature branch workflow. TeamCity is a continuous integration server that automates the building and testing of your software. The purpose of the post is to show how easy it is to integrate TeamCity to Git feature branch workflow in Deveo. If you would rather want to see the things in action, watch the video below:
For those who would like a written step-by-step instructions, read on.
Creating the repository and a bot account
We start off by creating a Git repository in Deveo. While Deveo supports all Git, Subversion and Mercurial, this post concentrates on Git. You may be interested in trying the functionality with Mercurial as well, as the steps in this post can be applied to Mercurial too. In Deveo, you create a repository always to a project. You can create a new project from the dashboard and create new repository under the repositories view.
In Deveo, bot accounts are used for granting external access to repositories and Deveo APIs. We use the bot account both to check out the code changes in TeamCity, as well as to send the build status notification through Deveo API. Bot accounts are created either through the project's Team view or from the Bots view in company scope.
Installing Deveo TeamCity plugin
TeamCity has a flexible architecture which can be extended in a number of ways (runners for new build tools and testing frameworks, notifiers, etc.) We have created a fork of the existing Commit Status Publisher plugin that now supports sending build notifications also to Deveo. The plugin for is tested with TeamCity 9.1.
In order to install the plugin, you need to clone the Git repository of our fork from GitHub. After you have cloned the repository, checkout the 9.1.x branch that contains the Deveo related modifications and build the package locally using Maven. If you have Maven installed, you may simply copy-paste the below commands to build the plugin package locally.
git clone https://github.com/Deveo/commit-status-publisher.git cd commit-status-publisher git checkout 9.1.x mvn package
After building the package you may find
target directory. To install the plugin, copy it to your TeamCity data directory. If you don't know where your TeamCity data directory is, you may use TeamCity web interface to upload the plugin package. Uploading the plugin packages can be done through the web interface, by browsing to
Plugin list ->
Upload plugin zip.
After you have copied or uploaded the plugin package, restart TeamCity. After restarting TeamCity the
Commit Status Publisher plugin should be visible under the Plugins list.
Creating a TeamCity project
Next, we will create a new project and a build configuration. Creating projects in TeamCiy happens through TeamCity administration web interface.
After creating a new project we add a new build configuration for our Git repository. Copy the clone URL from the Deveo project's repositories view to the repository URL. When using
HTTPS protocol, remove the username from the clone URL and use credentials of the bot account you created earlier. You'll find the bot account credentials by clicking the cogwheel icon next to the bot name in team view.
After adding the credentials, open the advanced settings, and set only feature branches to be built. This can be achieved by adding the following lines to
Branch specification settings:
The two lines above mean that we add all branches that are prefixed with
features/ to be built and remove
master branch from the branches that are built.
Configuring the commit status publisher to a TeamCity project's build configuration
Now that we have the repository configured using our bot account's credentials, we can add the commit status publisher plugin to publish the build results to Deveo. The commit status publisher is added as a build feature. Add a new build feature and choose commit status publisher. Choose Deveo as the publisher and fill in the deveo API hostname as well as the bot API keys which you can find from the bot details.
For the sake of simplicity, we do not configure any steps to the build configuration. We'll leave that as an exercise.
Creating a post-commit hook to commence the TeamCity build
Now that we have our TeamCity project and build configuration ready, including the build status notifier, we can add a post-commit hook that will automatically commence TeamCity builds after changes are pushed to the Git repository in Deveo.
Adding a post-commit hook in Deveo happens from the hooks view. In addition to the hostname of our TeamCity instance, we need the build configuration id (buildtype id), and credentials that have to access the build configuration. The build configuration id can be found from the build configuration settings.
Once we have everything ready, we can test our workflow. We start by creating a new feature branch locally. Remember to name it with
features/ prefix. After creating the branch, create some commits and push the branch to Deveo. Deveo should trigger the post-commit hook and notify TeamCity to commence the build we created. As the build passes, since we didn't have any build steps, TeamCity should send notification of a successful build status to Deveo.
We then create a new code review for the branch we pushed. As we received the build status notification to Deveo, the build status is already present in the code review details. It can be also used as a condition for accepting the review and merging the branch. Finally, we can merge the branch and additionally delete the branch.
Setting up a feature branch workflow using Git and TeamCity continuous integration server in Deveo takes a couple of steps. Once it's set up, it works as a powerful quality gate that denies any changes to be accepted to your main branch before the changes have gone through automated feedback.
What continuous integration server do you use and how is it tied to your feature branch workflow? If you are planning to set up a feature branch based workflow using TeamCity, try out Deveo.