Multiple VCS Trigger with different "Per-checkin Triggering" for different branches

683 Views Asked by At

I need two VCS Triggers with different Per-Checkin Triggering rules based on a banch filter.

The reason: For the "release-*" & "master" branch when I merge everything in i don't want a build created per checkin, however i do when using any of the other branches. I though i could do this by adding a second trigger filtering the branches so they looked something like this:

The first VCS Trigger, this will build all of these branches with "Trigger a build on each check-in" checked

-:*
+:refs/heads/hotfix/hotfix-*
+:refs/heads/develop
+:refs/heads/feature/feature-*

The second VCS Trigger, this will build all of these branches with "Trigger a build on each check-in" unchecked

-:*
+:refs/heads/release/release-*
+:refs/heads/master

enter image description here

(Please excuse my not so epic paint skills)

Is there another way I can do this?

Thanks

Steve

2

There are 2 best solutions below

0
On BEST ANSWER

The solution was to modify the build configuration XML. Steps were: Locate your TeamCity Project folder which is a subdir of the TeamCity Data Directory, mine was C:\ApplicationData\TeamCity\config\projects.

Find the build configuration in which every project subfolder it lives under example: C:\ApplicationData\TeamCity\config\projects\parentProj_Proj\buildTypes\build_config_name.xml

At the bottom of this file was where i found the build triggers section, find in there the current build trigger you have an duplicate it, but remember to change the "id" attribute on the "build-trigger" element. So my final config looks like this:

<build-triggers>
      <build-trigger id="vcsTrigger" type="vcsTrigger">
        <parameters>
          <param name="branchFilter"><![CDATA[-:*
+:refs/heads/hotfix/hotfix-*
+:refs/heads/develop
+:refs/heads/feature/feature-*]]></param>
          <param name="groupCheckinsByCommitter" value="true" />
          <param name="perCheckinTriggering" value="true" />
          <param name="quietPeriodMode" value="DO_NOT_USE" />
        </parameters>
      </build-trigger>
      <build-trigger id="vcsTrigger1" type="vcsTrigger">
        <parameters>
          <param name="branchFilter"><![CDATA[-:*
+:refs/heads/release/release-*
+:refs/heads/master]]></param>
          <param name="quietPeriodMode" value="DO_NOT_USE" />
        </parameters>
      </build-trigger>
    </build-triggers>

This although probably unsupported seems to work just fine.

1
On

I couldn't find how to add 2 VCS triggers on a single build configuration, have you tried that?

I'm on TC 10 though, but if that really doesn't work then only way i can think is just to create 2 separate builds. :|