TeamCity: How to setup proper trigger file wildcards

Viewed 210

Say I have a solution containing the following projects in a folder-tree (this is C# but could in principle be anything):

MySolution
- SharedFolderA
  - File1.cs
  - File2.cs
  - SharedProject.csproj
- SharedFolderB
  - File1.cs
  - File2.cs
  - SharedProject.csproj
- Hosts
  - Host1
    - Program.cs
    - Host1.csproj
  - Host2
    - Program.cs
    - Host2.csproj

Now in TeamCity I wish to make building of each host into seperate builds. So I will have a project called MySolution containing the following builds:

  • Build Host1
  • Build Host2

Now comes the question: For each build I want to setup a VCS trigger rule, that triggers the build if the commits contain changes to either

  • files in the root folder
  • files in one or more of the shared folders
  • files in the specific host folder - but not the other host folder

Example: Build of Host2 should trigger if any files have been changed in any of the following folders:

  • MySolution
  • SharedFolderA
  • SharedFolderB
  • Hosts/Host2

How should I setup the File wildcards?

1 Answers

The format is as follows from TeamCity Ref Perhaps consider a different approach, since you have different build/host conditions!


Option 1:

Since you have various hosts with build conditions, a dependency build with wildcards is (IMHO) **recommended, i.e. use the Artifact Dependency feature which in turn allows wild cards in files & folders picture below.

Team City Maven Wildcard Build Artifact Dependency


Option 2: However if you choose to go down your original Build Trigger Path, you can try this.

+|-[:user=VCS_username;]root=VCS_root_id;]comment=VCS_comment_regexp]]:Ant_like_wildcard

Trigger Rules

Once you have setup via the UI, you can make a copy and edit the triggers by adding modifying like so.

//all files, or .CS in the root folder
/root/**
/root/*.cs

//files in one or more of the shared folders
/root/SharedFolderA/**
/root/SharedFolderB/*.cs

//files in the specific host folder - but not the other host folder
/root/SharedFolderA/**
// the -ve sign will ignore it
-/root/Hosts/Host2/**

You can add regex or ** or ? singmatch

Sample Trigger Configuration


Related