How to skip building configurations which sources were not changed since the last successful build?

Despite the effort I still cannot full grasp the logic behind TeamCity build dependencies.

Example#1: We have standalone build configuration triggered by schedule. How to skip the build if source code was not changed since the last successful build?

Example#2: We have build chain connected by Snapshot Dependencies. Every time the sources for one build configuration get changeв the whole chain is built, including those configurations which sources barely ever change. How to avoid wasting time and resources?

Example#3: We have three build configurations which run different kinds of tests against the artifact from some primary build. How to initiate deployment "build" of that artifact only when all three "test" builds were successful? Or even more specifically - how to find (and deploy) the latest build for which all three test builds (potentially running in parallel on different agents) finished sucessfully.

In many cases it feels like "existing suitable build" is present, but TC does not take it as suitable.


Could somebody please clarify the confusion?

Thank you!
Konstantin

5 comments
Comment actions Permalink

Hi Konstantin,

  1. You can check option "Trigger only if there are pending changes" to restrict schedule trigger to start builds only if there are pending changes in the version control attached to this build configuration.
  2. To skip builds in chain, you need to enable option "Do not run new build if there is a suitable one" when configuring snapshot dependencies. If the option is enabled, TeamCity will not run a dependency build, if another running or finished dependency build with the appropriate sources revision exists. See when the build is considered Suitable. Please note, that if the VCS settings are different (VCS roots or checkout rules), then "same sources snapshot" revisions means revisions taken simultaneously at some moment in time.
  3. To run Deploy build after Tests you have to configure snapshot/artifact dependency from Deploy build to all Test builds. In this case Deploy build will wait for all Test to be passed.


For more details and examples please read these sections https://confluence.jetbrains.com/display/TCD9/Build+Dependencies+Setup, https://confluence.jetbrains.com/display/TCD9/Dependent+Build.

0
Comment actions Permalink

Alina, thank you very much for your answer. Now I need some time to experiment with those settings and see if I get what I want.

My primary concern is not scheduled build, but rather Deployment build triggered by VCS which has lots of Snapshot dependencies (direct and indirect) on other builds (components and tests). It is really confusing that it initiates build of ALL snapshot dependencies ignoring the fact that most of them are already built from the latest sources and do not need to be built again. I.e. the option "Do not run new build if there is a suitable one" seems to be too picky and rejects available builds which are otherwise totally suitable for consumption by Deployment.

Is there a way (through some verbose logging maybe?) to find out why existing build was not considered suitable and was rebuilt?

Thank you!
Konstantin

0
Comment actions Permalink

Konstantin,

Unfortunately at the moment we do not provide details why the build is not considered suitable. Please vote for the feature request: https://youtrack.jetbrains.com/issue/TW-37419. Also please vote for the related request: https://youtrack.jetbrains.com/issue/TW-35216.
Alternatively, it is possible to promote a finished build through its “Build Actions” and invoke configurations which are snapshot dependent on it. In this case the build chain won't be rebuild. Please find more details here: https://confluence.jetbrains.com/display/TCD9/Triggering+a+Custom+Build#TriggeringaCustomBuild-PromotingBuild

0
Comment actions Permalink

Is there a way to Promote a build automatically (without TC UI) using some kind of trigger?

0
Comment actions Permalink

In TemCity 9.1 EAP1 we have improved Scheduled Trigger to solve this request (also see suggested workaround in comments). The Schedule Trigger has got an ability to watch for builds in other build configurations and trigger a build if these builds change.
The watched build in this trigger will be promoted to a triggered build if there is an artifact or snapshot dependency on the watched build in the configuration where the trigger is defined.

0

Please sign in to leave a comment.