We finally got TeamCity doing our release builds. There were a couple of tricky points, which I thought would be worth writing up:
- Selecting the branch
- Manipulating the repository
- Ensuring correct (release) versions of dependencies
Selecting the branch
This was the trickiest thing. Checkin and nightly builds always run against trunk. Well, you could set up a checkin build for a long-running development branch too, but that's not difficult. The release build should be done from the release branch, and that can be different for each release. Or it can be the same, if you have to do a fix release on an existing one!
We found a pretty good way to do this with TeamCity, using Build Configuration Templates and Configuration Parameters.
The idea is that you set up a template that contains all of the settings for the release build, except for the branch name. The branch name is specified by a configuration parameter. Then, the template is instantiated for each branch as desired. Each time the template is instantiated, the branch name configuration parameter is given for that instance.
Here are some details, using Subversion VCS and a hypothetical project named "xxx":
Create the Release Build Template
- Edit project's existing checkin build config.
- Click "Extract Template" to create a new template.
- Enter "release-build-template" for Name.
- Back in the checkin build config, click "Detach from Template".
- Click OK.
We've created a template, with no configurations attached.
Set up the Release Build Template
Edit the template. Change settings as given in the following sections.Version Control Settings
- Create a new VCS root named xxx-branches.
- Specify Subversion as the Type of VCS.
- Enter Svn repo URL + "/xxx/branches" as the URL.
- Test the Connection.
- Save the VCS root.
- Attach the template to the xxx-branches VCS root.
- Detach the template from the xxx-trunk VCS root.
- Add checkout rule for VCS root: "%release.branch%=>.". This tells TeamCity to checkout the specific release branch into the working directory.
- Save Version Control Settings.
Runner Settings
- Change Target to "release-build", or whatever you want to call your release build target.
- Save Runner Settings.
The Ant target might look something like this:
Build Triggering Settings
- Delete/disable all triggering (VCS and Dependencies).
- Save Build Triggering Settings.
Create a Release Branch Build Config for Release xx.yy
This procedure creates a release build config for a particular branch.- Edit the release-build template's build configuration.
- Click Create Build Configuration From Template.
- Enter "release-xx.yy" for Name, where "xx.yy" is the name of your release branch.
- Enter the name of the branch for the release.branch parameter. For example, "RB-01.05".
To create a release:
- Ensure all changes for the release are checked into trunk.
- Create the branch. For example:
svn copy $SVN/xxx/trunk $SVN/xxx/branches/RB-xx.yy
- Click Run on the release build configuration in TeamCity.
You can keep the release build configuration around for a particular branch as long as you like. If you are finished with a branch, you can delete the build configuration. If you need it again, it's easy to recreate it from the template.
That's it. I hope to write up some notes on the other points (manipulating the repository and ensuring the correct release versions of dependencies) soon.