4

TLDR: How can I arrange it so that a snapshot dependency does not trigger new builds?

For my test processes to run, they need to run on a "Test" environment. Creating such an environment is simple, but lengthy; it can take as much as 45 minutes to an hour to finish building a test environment. Further, the name of the environment, and other such variables, is not fixed until the environment has finished building.

In my TeamCity build definition, I could put "build environment if missing" as a build step. However, that means that the first test of the day will take 45 minutes to run.

Instead, we created a separate build, that is scheduled to run every morning, that builds the test environment for the day. Our test build then has a snapshot dependency to that build in order to use the parameters of that build to determine the environment information, and everything works as expected, except for one issue:

When a new test is run, it frequently seems to trigger a rebuild of the test environment creation.

We don't want this to ever happen; the test environment creation is 'done' for the day and should not need to run again until tomorrow. How can we achieve this?

GWLlosa
  • 23,995
  • 17
  • 79
  • 116
  • Do you need a snapshot dependency? The only reason for one is to trigger dependency builds but yet this is what you're trying to avoid. – Paul Hunt Jan 26 '16 at 08:27

1 Answers1

1
  1. You already have time based trigger => environment will be prepared every morning
  2. Create Snapshot Dependency in your product TC configuration (not in that one which is preparing test environment) and tick 'Do not run new build if there is a suitable one'
  3. Your configuration used to setup test environment should not have any VCS root (or point to some calm place of source control where submits will not happen). To physical setup your environment you should not need any source code mapping etc. - you may consume everything needed through your own NuGet packages for example.

Note: In this workflow every build of your real project will enlist build of configuration which sets test environment (so it's physically in build queue) but when it's turn come up it will compare changes since last build => no submits on VCS found (it's pointing to calm place in SourceControl due step 3)) and so build will be skipped in <1s

Jaroslav Kadlec
  • 2,505
  • 4
  • 32
  • 43
  • 2
    We have some of the same problems and setting "do not run new build if there is a suitable one" doesn't always seem to do the trick. We see frequent rebuilds with "no changes" listed triggered by builds further down the line. – Lasse V. Karlsen Jan 26 '16 at 14:07
  • Is it really often? Those rebuilds may be triggered by events which TC predicts it may affect build output (for example change in TC configuration), TC config which is setting 'test env' should also not have any Artifact/Snapshot dependencies. It's working properly for us to assemble 80 TC projects spread across 5 dependency layers with no such issue (9.1.4 build 37293). What your're describing seems like bug in TC (deserving bug report) or issue with your workflow. Are you seeing anything interesting in cases where builds are triggered and they should not? – Jaroslav Kadlec Jan 26 '16 at 15:15