Lock shared resource to build chain

I really enjoy using the Shared Resources build feature.  The "custom values" lock type allows me to have a pool of database servers that my builds can use.  I am running against a limitation with how locks are assigned, though.  The lock is assigned to a specific build.  When that build finishes, the lock is released and any other build can then acquire the lock.  However, I have a chain of build dependencies, and multiple builds in the chain require the same lock.  I'd like to see the first build in the chain acquire the lock and hold the lock until the last build in the chain.  That way, all the builds in the chain will use the same database resource and, more importantly, other build chains will not be able to be assigned to that database until the first chain completes.

The figure below illustrates what I mean.  In this example build chain, I have a number of builds that form a dependency chain.  The light coloured boxes don't require shared resource locks, but the dark coloured ones do.  Ideally, a lock would be acquired at the start of the "apply database scripts" step and would be held until "restore database backup" completes.  TAll three builds that require the database will use the same one.  Also, if the "run unit tests" step takes a long time, no other build can sneak in and take this database for their own purposes.
buildchain.png
This feature would be super helpful to us.  Has anyone had experience trying to duplicate this kind of behavior in TeamCity?

3 comments
Comment actions Permalink

Hi Kyle,

Thank you for detailed explanation and provided example.
We have the related feature request in our tracker https://youtrack.jetbrains.com/issue/TW-36313. Please watch and vote for it.

0
Comment actions Permalink

Until then you can try to either do all this in a single build, or try to devise additional logic to your build scripts. Unfortunately we do not have better solution on TeamCity side now.

0
Comment actions Permalink

Thanks for the update.  Combining all my steps into a single build isn't feasible because our more complicated builds have dependency chains with fan-out to achieve parallelism.  I'll just keep an eye on the feature request for now.

0

Please sign in to leave a comment.