Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

When setting up a continous integration environment, does it always entail having the build server pull code and merge between branches?

Or is it something you NEVER want to do because you are depending on an automatic merge would usually ends up having issues (and requires manual intervention).

share|improve this question
    
-1: Did you consider the ramifications of automatic merging? –  Jim G. Aug 12 '12 at 23:38
add comment

6 Answers 6

up vote 8 down vote accepted

I've never seen a CI system doing any merging. In theory you could set it up to do that but as you mentioned the build will break if you run into any merge issues.

CI environments usually have a specific fixed branch as the "build" branch and the CI server will monitor that branch for new check-ins to fire off a new build cycle.

share|improve this answer
add comment

Never do that. Automatic merge is just one reason. Even more importantly, you should be able to commit to your branch until you've finished, without fear of breaking the trunk.

However, if you're using a tool like Jenkins, you might want to add a separate automated build for your branch, so that you continue to get fast feedback on commits.

share|improve this answer
add comment

CircleCI, my hosted CI service can be set up to do this. Circle automatically builds all branches by default. For our own code, green builds on master are automatically merged into the production branch. Of course, only do this if you have a good test suite.

Now, that case is easy, because nobody pushes to production directly.

I think there's a lot of interesting work that can go on here. Eventually, I'd like to get all bugfix branches to auto-merge into master on green. I've been in situations where I'm working on a bug, run all the tests, then discover I need to merge with master (rather than fast-foward), and forget to run all the tests again, and end up breaking the build.

A feature I'm interested in writing is comments in the commit message that say "merge with branch X, if it's green". That way, it's never possible to have master be broken.

The other responses here don't make a lot of sense to me. Your CI system doesn't have to be dumb. It should be able to gracefully handle merge conflicts, by not merging, and informing the user. And on any "shared" branch, like master or production, merges should always be fast forwards!

share|improve this answer
add comment

I haven't heard about any CI system that would automatically merge branches. Why? Because it is not always that easy, and even if you're using one of the most sophisticated DVCSes available out-there it is still possible that a human is required to review the code that has been changed. It is especially tricky when people have actually changed bits in the same file (i.e. same method in the class, same function).

I think automatic merging would do more harm than good. And in the end you (as a developer) don't want to waste your time on investigating issues that are not real issues, and happened just due to the fact that a piece of code was not as smart as you are, and couldn't figure out what the code after merging should look like.

share|improve this answer
    
The only times I've had to merge was when bits in the same file were changed, and only then when they were the same bits. –  James Aug 9 '12 at 20:07
add comment

Merging always needs to be done manually. If you design the software and manage the development with a degree of sanity, then conflicts will arise only on very, very rare occasions, but when they do occur, they need a human to ensure that the merged result makes sense.

To get the benefit of continuous integration, developers need to merge changes and check their work into a central repo/branch on a frequent basis (every hour or so).

share|improve this answer
add comment
Automated merge between branches? - That is simply not a good idea.

CI is a great process and needs to be setup for comparatively big projects. However, I would never trust to automated merging. Because, it is quit common to get wrongly merged files resulting in compilation error or even worth by unintended change in coding logic.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.