2
votes

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

Example: Under the dev branch, I have 2 folders:

(dev)
- 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
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.

Regards, Gunnar


Updated: This issue was resolved, but I can't remember how exactly and I'm too lazy to check it out. If however, someone encounters this and can't figure it out, feel free to let me know and I can most likely reproduce the problem and have a detailed answer if needed.

2

2 Answers

2
votes

@Gunnar, there is another way of doing it. You can create a Build Trigger,specifically a VCS Trigger, that will ignore any changes in your exclusive path. These work in the syntax of Ant-like wildCards. So you can create a trigger that says , run only for changes in ServiceAPI/ or one that runs for anything except ServiceAPI.Test/.

The syntax would be +:ServiceAPI/** or -:ServiceAPI/**.

PS:Also note that your default branch to monitor is different from the trigger conditions.

1
votes

@Gunnar, try adding both the + and - variations and see if it works. There are times when teamcity gets confused if you add a exclusivity operator.

-:refs/heads/dev/* 
-:refs/heads/dev/ServiceAPI.Test/*

Also, parameterize your GIT repo name so that you can pass in your branch name (that is to be monitored) as a parameter. IT will help in reducing the time it takes Teamcity to scan larger repo's

@Gunnar, by parameterizing I mean this: In your GiT repo setup in teamctity, for the default branch input , put in a parameter for ex %branch.name%. In your build target, if you mention the name of your branch using the parameter %branch.name%, it will only monitor the branch/ path that you are giving using the parameter . For ex if you give the param as develop in your build target , it will monitor only develop branch .

Once you do that, your exclusivity operator changes to

-:ServiceAPI.Test/*