TeamCity: Prevent 2 builds from running simultaneously
Asked Answered
S

3

17

I don't want Build Config A and Build Config B to run at the same time. This is because they share the same resource which cannot be accessed simultaneously. However each build config is run by a separate agent so it is possible for them to run simultaneously.

Instead I would like one build config, when triggered, to wait for the other to finish if it is running. For example if Build Config B begins to run but Build Config A is already running, then B would wait until A finishes and then B would run.

I don't think a snapshot dependency will work because that assumes one config has a dependency on the other which is not true in my case.

Sonar answered 22/1, 2013 at 21:16 Comment(4)
why can't they run independently? would they interfere with each other via a shared resource? could you pin them to the same agent?Alduino
Will the builds always run together? If so, you could remove all build triggers from one of the builds and assign a Finish Build solution to it. This will queue build B after build A finishes. That said, I still like Matt's suggestion of forcing them to both run on the same build agent.Devout
They can't run independently because of a shared resource. Ideally I would find a way around this but it will take some reconfiguring, so I'm hoping at least temporarily to prevent them from running simultaneously.Sonar
In that case, just make a rule on the agents tab, that they have to run on the agent name containing xxx ( whatever that is ) then those builds can only run on that agent and will never run at the same time.Fernferna
F
10

For a quick and dirty, just make a rule on the compatible agents tab for the project. That they have to run on the agent name containing xxx ( whatever that is ) then those builds can only run on that agent and will never run at the same time.

Fernferna answered 24/1, 2013 at 22:57 Comment(1)
I guess it would be nice if TeamCity just had an option against a build configuration i.e. Enable simultaneous builds which was on by default. Can't imagine it would be a difficult plugin to write, maybe I'll give it a go if I have time - however, in the meantime this workaround is more than acceptable :)Ureide
L
14

Keith, there are two plugins that can help you: The first one is Groovy plugin. It has functionality of creating name locks over all projects.

The second one is TeamCity.SharedResources. It has functionality of definig shared resources and locking them with read and write locks. However, resources defined in this plugin, are are defined per-project. We are actively developing this plugin, so you are welcome to watch its page in our tracker

Loupgarou answered 24/1, 2013 at 10:1 Comment(1)
Shared Resources is bundled with TeamCity as of v8.0 so that seems like the right answer now.Ate
F
10

For a quick and dirty, just make a rule on the compatible agents tab for the project. That they have to run on the agent name containing xxx ( whatever that is ) then those builds can only run on that agent and will never run at the same time.

Fernferna answered 24/1, 2013 at 22:57 Comment(1)
I guess it would be nice if TeamCity just had an option against a build configuration i.e. Enable simultaneous builds which was on by default. Can't imagine it would be a difficult plugin to write, maybe I'll give it a go if I have time - however, in the meantime this workaround is more than acceptable :)Ureide
T
3

In the newest version of TeamCity, you can configure this parameter. Go to the Edit Configuration Settings -> Edit Configuration Settings and set parametr:

Limit the number of simultaneously running builds (0 — unlimited)

Tabitha answered 2/6, 2019 at 8:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.