Prevent dependency builds with no relevant changes


In our current setup, we have a composite build per Git branch that has a VCS trigger; depending on the branch, we use reverse dependency environment variables to propagate different settings. The composite build uses snapshot dependencies to synchronize the code and get everything running that it needs; this includes linting in separate subprojects, building, deploying then testing those subprojects. These subprojects have shared code, and are all on the same repository.

What we need, is for subproject A to only build when there are changes in subproject A or its shared dependencies, similarly for all other subprojects. We also need these to all be a part of the same build chain, since the tests require multiple subprojects to be built in order to run. The not-great solution that we have had, is to have a VCS trigger for every subproject, but then we end up with multiple independent build chains and an enormous number of builds in the queue (most of which are removed when the build process realizes the change has been built).

So far, there hasn't been a lot of luck; we've been trying VCS checkout rules on the build for each subproject to hopefully prevent TeamCity from building the subproject when it has no relevant changes, but that has not worked.

Is there a way to prevent triggered build dependencies from building if they have no relevant changes? It seems like a necessary feature, given the amount of build agent time that would otherwise be wasted; presumably this is possible?.


Hi! It looks like you are looking for Checkout Rules. They 1) allow checking out only the files necessary for the build configuration and 2) affect which changes are detected by the build configuration and thus allow reusing the builds whose configurations don't have relevant changes.



Hi Anatoly Cherenkov , thank you for the response. Checkout rules is what what we are using. It does not appear to be working like you described, or like we had hoped, but it is good to know that this should work. I am going to try out a more stripped down setup to figure out why checkout rules are not working for us. I'll update once I have this done.


We are still seeing the same Anatoly Cherenkov . We have a build configuration with a trigger, that has a bunch of snapshot dependencies. These snapshot dependencies run regardless of whether or not there is a change in the parts of the VCS limited by the checkout rules. Should this kind of setup work? If not, are there alternatives setups that would keep everything in a single build tree, but avoid dependent builds being run when there are no relevant VCS changes?

I have confirmed that the files being pulled to the build agents are as expected given the checkout rules. It just seems that they're building regardless of relevant changes.


Please sign in to leave a comment.