Help with Branch specification settings. VCS trigger not working as intended.


I have a Git repository with 3 classic branches (dev, staging, master).
I'm trying to setup a VCS, so that a build triggers only when a push is made to a specific subfolder in the repository.

Under the dev branch, I have 2 folders:


- ServiceAPI

- ServiceAPI.Test

Now, I want TeamCity only to trigger a build when I push a change in the ServiceAPI folder, not the other one (ServiceWeb.Test).

I have tried to setup a few different configs (I figured this could be done using Branch Specification, but it doesn't work, or I'm doing it wrong).

In the VCS configuration I have Default branch set as dev
and I have Branch specification set as +:refs/heads/dev/ServiceAPI/*

Assuming that the Default branch is always active, I tried adding -:refs/heads/dev/* in the Branch specification to cancel it out, but it doesn't work.

I also tried to put a different branch than dev in Default branch, but then the trigger didn't work when pushing changes in the dev branch, regardless what is in Branch specification.

Then I tried excluding the ServiceApi.Test folder by inserting -:refs/heads/dev/ServiceAPI.Test/* to Branch specification, but that didn't work either. TeamCity builds when I push changes into either folder.

I hope I'm explaining the problem well enough. Please let me know if you need more information.
Any ideas would be most welcome.


1 comment
Comment actions Permalink

The way you are trying to do is not correct, because of the way GIT's branch naming works. refs/heads/dev/ServiceAPI.Test/ is just an another branch name (dev/ServiceAPI.Test), which is obviously not what you are expecting.

To achieve the desired result, you need to configure VCS trigger ( to trigger build only after commit at a certain path.


Please sign in to leave a comment.