Reputation: 3276
I want to achieve the following:
I have enabled "treat tag as a branch" checkbox in VCS configuration.
I have tried configuring it but I am not able to get it working. Following is my VCS setting:
and following is how I have configured my build trigger:
I don't want to trigger a build manually. My idea is that TeamCity should be able to pick up this new tag and run the build. Any pointers to achieve this objective would be helpful.
Upvotes: 16
Views: 9458
Reputation: 21
I recently had the same question and this thread helped to find the solution with one alteration to @jsaddwater answer:
Instead of creating two VCS Roots in the Version Control Settings just under the VCS Roots list click on -> Show advanced options and add in the Branch Filter:
+:*
-:<default>
Upvotes: 1
Reputation: 10350
My configuration is very similar, but yet slightly different, to the @jsaddwater's one:
Version Control Settings > Branch Filter:
+:*
-:<default>
Version Control Settings > VCS Root:
Default branch: master
Branch specification:
+:refs/tags/*
-:<default>
Triggers > VCS Trigger:
Parameters:
Add or set Configuration Parameter: teamcity.vcsTrigger.runBuildInNewEmptyBranch
with the value = true.
Tested and working on TeamCity 2019.1.5.
Upvotes: 1
Reputation: 1829
Since I haven't found any complete answer I thought I'd spare someone a couple of hours of hit-and-miss work. I didn't manage to ONLY build tags by editing branch specifications. Using a branch specification in the VCS trigger as well as in the VCS root leads to no builds. Adding a -:refs/heads/dev branch specification will still build commits in the branch. As a workaround one could create an unused branch, and specify that as the default branch. That way, since noone commits to that branch, no regular commits will be build, and tags will always be built.
This is how my setup looks like:
Upvotes: 5
Reputation: 1803
You've got it nearly right. You can use configuration parameter teamcity.vcsTrigger.runBuildInNewEmptyBranch=true
to tell TeamCity to build on tag creation -- https://youtrack.jetbrains.com/issue/TW-43606. Otherwise TeamCity won't trigger a build when you see a new tag.
Upvotes: 12