1
votes

We want our Teamcity server to do an automatic build whenever someone merges something back to the master branch.

To do this we have created a new VCS Trigger and checked the Trigger a build on each check-in-option. We have disabled the Quiet period mode and added a regular expression for the trigger rule. Checking out the Java regex documentation I've created the following regex: ^Merge branch '[a-zA-Z0-9\p{Punct}]+' into 'master'$ which translates to the following in the Trigger rules textblock: +:comment=^Merge branch '[a-zA-Z0-9\p{Punct}]+' into 'master'$ or +:comment=^Merge branch '[a-zA-Z0-9\p{Punct}]+' into 'master'$:** (I haven't got the slightest idea what :** should do, but the TC documentation uses this sometimes)

This should match something like:

Merge branch 'test' into 'master'

or

Merge branch 'feature-cs-200' into 'master'

However, the builds are never triggered. Apparently the regex doesn't match the correct pattern.

Any ideas?

Finished... Apparently Teamcity has decided the +:comment=^Merge branch '[a-zA-Z0-9\p{Punct}]+' into 'master'$ regex is fine now and triggers the builds whenever a commit message matches the examples. Perhaps there was some caching or something else which caused the trigger not to fire.

1
why not just trigger on a commit to master? The merge will create a commit... - Sam Holder
The reason we want this is because Teamcity will trigger 2 (or more) builds this way, one for the 'merge person' and one for the authors of the branch to be merged (because of the option: Include several check-ins in a build if they are from the same committer). This isn't a big problem, but it causes some overhead. Therefore we decided, for now, only builds are triggered if they are merged in this way. - Jan_V

1 Answers

1
votes

I am not sure why you want to trigger your builds only on commits that contain the word "merge into". If someone does a fast-forward merge, the commit messages won't record a merge message. They will instead record a list of commits. You will never get a list of trigger.

Anyways, if you still want it to run only on merges to master, you can setup a VCS trigger on master(only) and run a teamcity target whenever the message is +:comment=into master:**

If nothing works, you can just try matching the regex '+:comment=Merge branch .* into master:**'