Reimplement "Build only modules affected by changes" for Maven using build configurations?


I have a git-based multi-module Maven project. I want to only rebuild/test changed modules and their dependencies. Checkbox "Build only modules affected by changes" does not work for me *and* does not provide enough control over build configuration.

Is it possible to reimplement it using TeamCity's build configuration dependencies?

  • Module A is very slow to build and test, almost never changes
  • Modules B and C depend on A, are fast to build and test, change often
  • Module D depends on B and C

I've read articles about dependencies and build chains in TeamCity and don't quite get how should I setup my builds.

  • How should I configure three build configurations that would mimic what "build only modules affected" already does out of the box?
  • Is it possible to run build configs for B and C in parallel?
  • I'm ready to manage additional complexity of getting build configurations A, B, C and D to speed up my builds enough.



Comment actions Permalink

Hello Timothy,

You can configure the following dependencies:

  1. Snapshot dependency from B and C build configuration to A
  2. Snapshot dependency from D build configuration to B and C

Configure all snapshot dependencies with option "Do not run new build if there is suitable one" enabled.
In this case, if build D is triggered the whole build chain A, B, C and D build will be added to the queue. If there are no changes in A, B or C build configurations they won't be rebuilt. B and C configuration will run in parallel.

If you have any further questions, please feel free to ask.

Comment actions Permalink

How can I avoid running A on each git commit?

When "there is a suitable one", does it mean same git commit hash?

Looks like the source of my confusion is how TC handles git checkouts when different directories are different projects.

Comment actions Permalink

Hi Timothy,

The build is considered suitable if it uses the required sources snapshot (revision of the sources being the same or taken at the same time if the VCS roots are different) and there were no changes in settings of the build configuration. For more details see Suitable builds section. So if there are no pending changes in A build configuration, it won't be triggered.

If you do no want to trigger build on each check-in you can configure Quiet Period in VCS trigger. 


Please sign in to leave a comment.