How to limit to 1 concurrent build across all available agents

Hi

We have some build configurations that can run on any agent, however, only one of these builds should be allowed to run concurrently at any time.  Is this possible to accomplish using the TeamCity configuration?  The "Limit the numer of simultaneously running builds" setting seems to only apply to an individual build configuration.  I want it to apply a whole set of build configurations.

Thanks

7 comments
Comment actions Permalink

It seems you need something like locks. TeamCity Groovy plugin (http://confluence.jetbrains.net/display/TW/Groovy+plug) has ability to emulate read / write locks on per build level. With help of it in your build configurations you can add special property:
system.locks.writeLock.<lockName>

with the same lockName. Then if a build is running with this property, any other build requiring this lock will wait.

0
Comment actions Permalink

Pavel

This might work.  How would I go about using it in my build scripts though.  We are using the MSBuild runner for automating most of our build tasks.  What do I need to do in my scripts to check for the lock and when it starts executing set the lock?

Thanks

0
Comment actions Permalink

No, you do not need to modify your scripts. TeamCity itself (Groovy plugin) will raise lock when build with such property starts and releases it when build finishes.

0
Comment actions Permalink

Just to verify - so all I need to do is to create an environment property named system.locks.writeloc.<mylockname> to all my builds that should not fire off concurrently?   When the build completes, the lock is automatically released to allow the other builds to continue?  Do the other builds still queue up in the build queue if the lock is already taken?

0
Comment actions Permalink

Yes, you should add system property system.locks.writeloc.<mylockname> to all configurations requiring exclusive access to resource <mylockname>. Builds of these configurations will wait in queue till lock is released by a build. Other builds of other build configurations won't be affected.

0
Comment actions Permalink

This sounds good. I recon it will also work if I configure the system property on the project level, right?

0
Comment actions Permalink

Yes, project level property should work too.

0

Please sign in to leave a comment.