How to deal with two projects in the same repo, one depends on the other?

I have one SVN repository, with two Java projects: "A", which is a library that produces a .jar file as artifact, and "B", which depends on that artifact. Those two projects are in two different folders within SVN "trunk" directory. So I have set up two projects in TeamCity, one for "A" and one for "B", each of them with its own build configuration.

For each of these build configurations I have set up a VCS trigger: as soon as a file changes in either of the two folders in SVN, that project is build by TeamCity. That part works fine.

Now, since "B" depends on the artifact from "A", which I have defined as dependency in TeamCity, I also want to trigger a new build of "B" after "A" has been successfully build and and generated a new version of the artifact. So I have set up a second trigger for "B", to start a new build in that case. This is also working well.

The issue now is the following: When I check-in files for both projects in one commit, then both build configurations are being triggered because of their respective VCS triggers. However, the build of "B" is triggered two times, once becaues of the VCS trigger, and a second time because of the project dependency trigger. But this is unnecessary, because "B" has been re-built once because of the VCS trigger anyway.

Is there any way in TeamCity 9 for me to define that "B" should only be built once in such a case?

4 comments
Comment actions Permalink

Hi Matthias,

In this case I would recommend configure:

  1. snapshot dependency from B to A
  2. artifact dependency from B to A with "Build from the same chain" option.
  3. VCS trigger for B configuration with option "Trigger a build on changes in snapshot dependencies" (no trigger for A build configuration)
0
Comment actions Permalink

Hi Alina, thank you very much for your reply.

I am not sure though -- if I use the "Build from the same chain" option, wouldn't that mean that A will be built everytime B needs to be built? The idea is that if A has not changed, but only a SVN file for B, then it is fine for B to use the last artifact from A from a successful build. So in other words: A does not need to be built in any case. of if VCS has changed.

Or did I misunderstand you?

0
Comment actions Permalink

There is a snapshot dependency option "Do not run new build if there is a suitable one" enabled by default. In this case TeamCity optimizes the queued builds by using an already finished builds instead of the queued ones. Corresponding queued builds are then silently removed.

0

Please sign in to leave a comment.