2
votes

In teamcity is it possible to restrict build agents to specific branches?

There are some interdependencies between my build configurations and I need the same build agent to build the same branch. If left to its own devices teamcity sometimes activates a new build agent for something later in the chain. This then fails.

What I'd like to do (at least until we can perhaps improve our build configurations to make them independent (artifacts?)) is assign one build agent to a branch. That would at least get things moving.

Thanks

2
Do you use GIT as VCS? How are the Branches specified in your build configs? - Mecaveli
Yes, git. The branches aren't specifically mentioned in the build configs except in the triggers. The problem is that say Step 3 is dependent on the same agent having done Step 2, so if Teamcity decides to use a different agent for Step 3 to Step 2 it fails. - Ian1971

2 Answers

2
votes

Like Alina already stated, you should not use the same configuration for multible "long-life" branches.

It´s very simple to create a build config for each branch:

  1. Go to your existing Build Configuration
  2. Introduce a %Branch% Parameter and adjust checkout rules etc.
  3. Use "Extract Template" to create a template out of it
  4. Create one configuration for each branch (dev / int / release) from the template, all you need to change there is the %Branch% Parameter

That´s where TeamCity shines imo.

1
votes

It looks like misuse of Feature Branches in TeamCity. Feature branches are for short-lived branches. For long-lived branches it's recommended to create separate build configurations and set up agent requirements per build configuration.