Teamcity auto build dynamic named branch
Currently having issues with team city build triggers on release branches.
Following gitflow convention we currently branch off develop and create a release branch, e.g release/1.0.0
What I am trying to do is when this branch is created/pushed too have team city run a build automatically.
I have created a VCS root specifically for the release branch and have it set up like:

I have my branch filter like this:

And added a VCS Trigger that looks like this:

Or in code
vcs {
quietPeriodMode = VcsTrigger.QuietPeriodMode.USE_DEFAULT
branchFilter = """
+:release/*|<default>
-:*
""".trimIndent()
}
As you can see I need to select the branch

What I ideally want is for team city to CI where the trigger will auto start the build for each release branch.
Where have I gone wrong, or am missing?
Please sign in to leave a comment.
Hello Jacob,
The correct syntax for the branch filter would be:
This way, only the changes in branches that start with release/... or the default branch will trigger a new build. The build should be started shortly after the change is detected - when you see it in the Pending Changes tab on your build configuration overview, you should expect it to be processed automatically soon.
Please let me know if this helps.
@...
Thanks for coming back to me.
I made those suggested changed, pushed some changes to my release branch (release/3.0.1) via a PR and no build has been triggered automatically, I still have to hit Run and select the branch?
Hello Jacob,
Sorry, I have missed an important detail from your description. With the following branch specification:
the logical branch name (the one that you see in TeamCity UI) will be the part matched by the asterisk (for example, if branch name is release/1.0.1, the logical branch name would be 1.0.1). However, branch filters also use logical names, and since the logical names are lacking release/ prefix, these branches do not trigger a build.
May I suggest to change the branch specification in your VCS root as following?
Parentheses mean that everything that is captured by them should be a part of the branch logical name - so the branch filter in the VCS trigger settings will correctly process these branches. Please also note that you may need to create a new branch or make a new commit in a release branch so that TeamCity triggers a build there.
Please let me know if this helps.
Hello @...
Thanks, I have done this and looks like the trigger has picked it up but it now looks the build name uses the whole branch instead of just x.x.x:
This messes up the packages etc
Hello Jacob,
I see - you may consider setting the build number from the build itself via service messages. This way you could prepare the build number basing on the full branch name (e.g. via command line step) and emit a service message to update the build number accordingly.
Hello @...
Currently I set the build number like:
With the changes you suggested (which did work) it would mean we do get the wrong build number, are you saying we cannot do it this way any longer?
Hello Jacob,
There are two options:
1. You may leave the current setup (where branch specification uses (release/*)) - this way, you are able to target the release branches in your VCS trigger specifically, but you will need extra steps for the build number formatting;
2. You may amend branch specification to +:refs/heads/release/* and amend branch filters to
This way, only release branches will be collected by the VCS root, and you will be able to use the build number format you currently have - but if you need to also build other branches in this build configuration, this would not work.