36

How can I configure TeamCity to build from SVN trunk and also from different branches and/or tags ?

Our idea is to have multiple builds from the same project, this way we can have the current version that is in production (with the ability to make deploys and fixes over that "release tag") and at the same time have the trunk and branches with the actual development that is taking place daily.

We have our policies, owner and all that for our SVN directories, the problem that we have is how to configure TeamCity to make multiple builds for the same project over the different "versions" or "states" of the application.

What is the best way to do this ?

Thanks in advance !

a4bike
  • 641
  • 1
  • 6
  • 11
  • You may also want to upvote the feature request in the JetBrains tracker: https://youtrack.jetbrains.com/issue/TW-18911. – sferencik Sep 23 '15 at 12:25
  • Possible duplicate of [TeamCity Projects and Multiple SVN Branches](https://stackoverflow.com/questions/893193/teamcity-projects-and-multiple-svn-branches) – Tamara Koliada Jan 02 '19 at 14:51

2 Answers2

44

First, ensure your VCS root is the root of your SVN repository in your administration panel, instead of being pointed to the trunk directory.

Then, for each build configuration, edit the checkout rules in your VCS Configuration. Add the checkout rule you desire.

For example, for your 'trunk' build configuraton, you would have a checkout rule of: +:trunk => ..

If you have a tag or branch you want to build, just create a new build config with a corresponding checkout rule. A tag of 'release-1.1' would have a checkout rule of: +:tags/release-1.1 => .

Here is the documentation on checkout rules: http://confluence.jetbrains.net/display/TCD65/VCS+Checkout+Rules

codeprogression
  • 3,011
  • 1
  • 19
  • 15
  • Hey Richard, thank you for the quick reply. I think I understand your idea (I'm kind of new with TeamCity), I'll give it a try; but I have a doubt: Do I need to make one build configuration for each version that I need ? or Is there a way to have just one build configuration with multiple build outputs from different sources ? Thanks again ! – a4bike Jul 29 '11 at 16:40
  • 2
    I would advise one per version, especially if you are doing build on check-in or want a understandable build history. You could define a configuration parameter to pass into the checkout rule and run a custom build each time (using the [...] on the run button, but it may be more trouble than multiple build configurations. I am assuming you are worried about limitations of the free version - but, by the time you need the full version, the price is worth every penny. – codeprogression Jul 29 '11 at 16:56
  • If you are new to TeamCity, check out my blog series. Its a little old (version 4.5), but the concepts are very relevant and most of the configuration is the same. http://elegantcode.com/2009/05/04/implementing-teamcity-for-net-projects-evolving-your-build-automation-solution/ – codeprogression Jul 29 '11 at 16:58
  • @Richard what do you mean "One per version?" One build configuration per version? So i'd have a build config for trunk and another for branch v1? – dalcantara May 03 '12 at 21:15
  • Yes, create a build configuration for each branch you want to build, then edit the checkout rules. TeamCity doesn't handle multiple branches with one build configuration on its own - your build script would have to handle that scenario. Its cleaner to have one build config per branch in TC. – codeprogression May 11 '12 at 14:43
  • 1
    How does this change now that TeamCity (from v7.1) includes support for feature branches? See http://blogs.jetbrains.com/teamcity/2012/08/07/teamcity-7-1-control-the-flow/ for details. – Bevan Sep 20 '12 at 03:02
  • 2
    TeamCity 7.1 feature branches seem to be a Git/Mercurial only feature. Looks like SVN would still require multiple branches. That said, if you are doing feature branches, you should be using a DVCS like Git or Mercurial. Well...I think you should be using one anyway. ;) – codeprogression Sep 21 '12 at 07:49
2

I had similar problem with SVN in TeamCity and to allow work with multiple branches I used Configuration parameter to pass "branch" since TeamCity doesn't support multibranch for SVN. enter image description here

And set trigger to start build from that branch: enter image description here

So in project it looks like: enter image description here

Tamara Koliada
  • 1,222
  • 2
  • 11
  • 30