TeamCity triggering on file changes in branch of branch
Hello,
In our setup, we've got triggers set up to only run build configurations when changes made in the appropriate directory has been checked into our VCS. We've found that if a branch is created from a non-default branch, all changes in the non-default branch will also be taken into account when TeamCity tries to find which builds should trigger. Is it possible to change this functionallity? Google searches and our own investigations didn't turn up anything clear.
To give a simplified example:
Lets say our repository has the two directories “A” and “B”. No changes are ever made in the root of the directory.
We have two build configurations, Build_A, and Build_B. These have the triggers “+:A/**” and “+:B/**” respectively.
In our default branch ‘develop’, I create a new branch “FeatureX”, change something in the A-folder. I commit and push, and TeamCity triggers Build_A, as expected. Build_A then finishes successfully.
I then create “FeatureY”, based on the changes in “FeatureX”, change something in the B-folder. I commit and push, and TeamCity triggers both Build_A *and* Build_B. This is not the sought behaviour for our workflow.
I would like only Build_B to be triggered in this case, as there's a successful build of Build_A already present.
I could also accept that only Build_B triggers, even if Build_A was unsuccessful in the branch “FeatureX”.
Is this in any way possible?
Please sign in to leave a comment.
Hi Bergsten,
You can achieve this using a trigger rule.
For Build_B, you can add the following trigger rule:
+:comment=#teamcity-B-folder:**This will trigger the build if the commit comment contains the keyword #teamcity-B-folder. And you can change the keyword as you need.
For more details and examples, refer to the TeamCity documentation on VCS triggers(https://www.jetbrains.com/help/teamcity/configuring-vcs-triggers.html#trigger-rules-examples-1).
Best Regards,
Tom
Hi Tom,
There's no way to be able to achieve this without adding a tag in every commit that has modified folder A, B, C, …?
The TC documentation on VCS triggers was one of the first places I looked, but I've previously found flags or settings that are not necessarily documented where I expected them to be documented.
Regards,
Bergsten
Hi Bergsten,
You can also use the branch filter to limit the scope of branches that trigger a build.
For Build_A, add the following branch filter:
+:FeatureX. //replace with your branch nameFor Build_B, add the following branch filter:
+:FeatureY//replace with your branch nameThis ensures that each build is only triggered by changes in the specified branch.
Hi Tom,
Thanks for your response, but this approach doesn't quite fit our workflow.
Our branches are short-lived and don't follow a consistent naming pattern that can be easily correlated to specific folders. The nature of our development means that a branch might touch different folders at different times, and the names of the branches are dynamic. We can't rely on branch names to determine which build configuration should trigger.
The issue we're facing is that TeamCity seems to take into account all changes from the base branch (which may have changes in unrelated folders) when determining which builds to trigger in a new branch. We would like only the relevant build configurations (based on actual changes in the folder) to trigger, regardless of what happened in the base branch.
Do you know of any way to achieve this without relying on branch names or commit comments?
Best regards, Bergsten
Based on my opinion, In your case, relying on commit comments is the simplest and most effective approach.
Best Regards,
Tom