Automatic merges of feature branches

Hi,

We're using TeamCity Professional 9.1.1 and I'm trying to get automatic branch merging working. Using Git/Stash our scenario is that the devs create feature branches from master named feature/name-of-feature. Once the feature is ready for testing they merge the branch into an integration branch and once that build succeeds they merge into a QAT branch. We'd like to automate this chain from teamcity.

I've managed to get feature and bugfix branches building automatically by adding this to our Branch specification: in the VCS root for the master branch

+:refs/heads/feature/*
+:refs/heads/bugfix/*

But I'm struggling to get the feature branches to merge automatically into the integration branch. I've added an automatic merge build feature and I've tried various combinations of 'Watch builds in branches' and 'Merge into branch:' Currently I have

+:feature*
+:bugfix*

and

integration

and I've also tried

+:feature/*
+:bugfix/*

and

+:refs/heads/feature/*
+:refs/heads/bugfix/*

The builds are successful but the branch doesn't get merged into integration and there are no messages in the log.

Any ideas what I'm doing wrong?

 

7 comments

Hello, Ian.

Please try to define your branches in the branch spec as

 +:refs/heads/(feature/*)

 +:refs/heads/(bugfix/*)

Does it help?

0

Hello Inna,

I don't think my branch spec is a problem as my feature branches are building correctly, it's the automatic merges I'm not sure about in the 'Automatic merge' dialog box, what should I type into the 'Watch builds in branches' and 'Merge into branch' fields?

As I mentioned above I've tried a number of combinations but none seem to work.

Thanks

0

Hello Ian,

In automatic merge build feature you should use logical branch names. If you have branch specification configured as

+:refs/heads/feature/*
+:refs/heads/bugfix/*

then the part matched by * is a logical branch name. If the branch specification pattern uses parentheses, the logical name then is made up of the part of the name within the parentheses. Please configure correct patterns.

To debug auto-merge please check teamcity-vcs.log file.

0

Hello Alina,

What would suggest I look for in teamcity-vcs.log? I've checked this file but I can't see anything related to automerge.

Given that all of our feature branches are named feature/SAT-nnnn-name-of-feature, I have added +:SAT* to the 'Watch builds in branches' field in the Automatic merge dialog box, this now appears to attempt the merge. However the merge now fails with the following error.

Automatic merge failed: Cannot find destination branch to merge into: no VCS branch maps to the 'integration' logical branch name according to the VCS root branch specification

My default branch in VCS root is refs/heads/master but I've also tried refs/heads/integration.

My target branch for merges is named integration what do you suggest I type in to the 'Merge into branch:' field? I've already tried integration but I keep getting the above error message.

 

0

Could you please attach screenshot of your current branch specification and Auto Merge build feature settings? 

0

Hi, 

We had the same exact problem as Ian. It all came down to understand correctly this response:

Please try to define your branches in the branch spec as

 +:refs/heads/(feature/*)

 +:refs/heads/(bugfix/*)

https://teamcity-support.jetbrains.com/hc/en-us/community/posts/207123175/comments/207076995

What the above does not make clear is the distinction between Default Branch and Branch Specification. In our case it worked when we specified

- Default = master

- Branch Spec = logical names of both source (Master) and target (hotfix) of the automerge = +:refs/heads/(hotfix) AND +:refs/heads/(master)

The mistake we were making previously was NOT including Master in the Branch Spec, and also of not specifiying the logical names.

In the Build Feature we then specified master and hotfix as shown in the attached screenshot

0

Yes  After adding branch specification as indicated above, worked fine for auto merge. thanks

0

Please sign in to leave a comment.