How to trigger build after any other build?

Hello,

"Finish build trigger" requires selection of specific build configuration. I want job to be triggered after whatever other build configuration in some top-level project is finished.

Why? I have a job that goes through all builds (asking them through TC API) and draws a heatmap success/failed.

Say I have 

Root
-heatmap job
-project_with_many_subprojects
--project1
---build
---test
--project2
---build
---test

I want "heatmap job" to start if whatever has finished under "project_with_many_subprojects"

Optionally I want it to be triggered only by any finished build in default branch.

 

Any solutions?

0
5 comments

Hi Gleb,

there are many options to do this. First, you can set up the "heatmap job" build configuration to have a snapshot dependency on all of your builds that need to be tracked, configure the dependencies to not rebuild if a suitable build is available, that way when there are changes, the heatmap job will get triggered, all other jobs will be parsed and only those with changes will actually be triggered. All other configurations will get parsed and might get built if teamcity considers that it's necessary (https://confluence.jetbrains.com/display/TCD10/Snapshot+Dependencies), but other than that, this is the easiest way to have a single configuration depend on many.

Another option would be to modify all the existing configurations, adding a final build step with a script that uses the REST API to trigger a build.

Yet another option would be to create a template instead of a build configuration, then create a configuration based on the template for each of your current configurations, set up a snapshot dependency to each of them, trigger it on changes in the base configuration. This way only the current configuration that has changes will be parsed, no "accidental" triggers will happen, but it requires a lot more maintenance, plus building a new configuration each time you add a new project (the initial suggestion only requires adding a snapshot dependency)

0
Avatar
Permanently deleted user

Hello Denis,

Thank you for your answer.

So far first suggestion seems the less-manual-work one, but it still means that adding new configuration will require to update heatmap snapshot dependencies?

As I understand, I cannot set it to track "everything that exists under top-level project", as there are checkboxes..

We add build configurations quite often, updating heatmap seems like annoying step :\    I looked into API but looks like that I cannot programmatically set snapshot dependencies (was thinking about auto-updating them will all existing buildTypes)

0

Hi Gleb,

yes, the first suggestion is the one that requires less work and maintenance, that's why I put it first. There is another possibility that I forgot to mention, not to perform the task you want, but to ease the process of any of the other options I suggested. Since 10.0, we offer the possibility to keep track of projects under versioned settings in Kotlin. The advantage of Kotlin is that it's code that is compiled when it gets to the server, which means that it's easier to make dynamic systems (although when there is a change, such as a new project or build configuration, the code should be changed, or it won't get automatically parsed).

In Kotlin, you could probably create a function that creates automatically the dependencies to all configurations in a project/all configurations that meet some condition, that way, just adding the new configuration will pick that up automatically, and when the new configurations are created, the dependencies will be added as well.

More on how to implement it here: https://blog.jetbrains.com/teamcity/2016/11/kotlin-configuration-scripts-an-introduction/

0
Avatar
Permanently deleted user

Hello Denis,

ok, got the idea. 

Going back to snapshot dependencies - any way of making heatmap run only when snapshot dependency build happened on default branch? 

0

There are some possibilities. Normally, when setting up a Snapshot dependency, you move the triggers to the last build in the chain, and select "Trigger on changes in snapshot dependencies". The possibility here would be to keep both the regular trigger in the original build, and add a new one on the heatmap one. Then filter out the default branch in the other configurations triggers, and leave only the default branch for the heatmap one. That way, a commit in non-default branches will only trigger them to build, while a commit in the default branch will trigger the heatmap, which in turn will trigger the builds to build the default branch commit.

Another option is to not filter anything but add an initial script to the heatmap that checks whether the last commits were in the appropriate branch. This would require some work to make sure it works, but can be done.

0

Please sign in to leave a comment.