17
votes

I have a Git setup with the typical master --> develop --> feature structure. I have 5 TeamCity (v8.1) build agents. Is it possible to configure TeamCity so that if multiple people commit to develop at the same time, the develop branch won't run concurrent builds? Part of our CI process is deploy-on-success, so I don't want two builds to be deploying to the same endpoint at the same time.

(I would want this setup for all branches, not just develop)

3

3 Answers

15
votes

On the General Settings configuration page you can set the number of simultaneous builds to 1 instead of 0 for unlimited. This means that it am queue up say 5 builds but only 1 will run at a time.

8
votes

Are you trying to prevent multiple check-ins to the same branch from generating multiple builds for that branch? You can do this without changing the concurrency settings by settings some options on the VCS Trigger portion of your build configuration. There is a 'Quiet Period' setting that waits for X seconds before doing a build, just in case several commits come in at once.

Here's a screenshot of the relevant menu in TeamCity 8.x:

Screenshot of the TeamCity menu for configuration the quiet period on a build configuration.

EDIT: Another option is the Build Features -> Shared Resource feature. This allows you to create a lock, associate it with one or more projects, and have them use it. This is useful to prevent 1+ projects from building at the same time. This is more reliable than the quiet time feature since there is an actual lock and not just a delay, though the quiet time does help collect multiple near-simultaneous checkins and so is independently useful.

1
votes

Combining a quiet period long enough, but not too long :), and 1 build max at same time, you should be able to get what you want. It's what we use here, quiet period from 120 to 180 seconds, and it works well.