Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

merge before build in jenkins fails but should not

Tags:

I have setup jenkins to build all feature branches in a project and before the build merge them to 'develop' since I'm more interested if the result of the merge builds rather than the feature branch itself.

This seem to work if the feature branch is based of develop HEAD but if the branch off point is before develop HEAD then jenkins says: ERROR: Branch not suitable for integration as it does not merge cleanly

And this would be alright if there was a conflict. But there is no conflict. I have tested the merge manually in the console and the merge is automatically done.

Also if comparing the feature branch and develop in atlassian stash it also shows a clean diff without any conflicts.

I'm lost. Why can't jenkins merge it?

like image 533
tkarls Avatar asked Dec 19 '14 14:12

tkarls


People also ask

Can merge conflicts be avoided?

creating pull requests. Avoid allowing pull requests to become stale. Make sure you're not changing the same lines of code before merging a prior change. Establish and follow formatting rules.

How do you check if there will be a merge conflict?

To see the beginning of the merge conflict in your file, search the file for the conflict marker <<<<<<< . When you open the file in your text editor, you'll see the changes from the HEAD or base branch after the line <<<<<<< HEAD .

Does merging overwrite?

Git doesn't overwrite until you mark the files with conflicts as resolved (even though if they really aren't). Git doesn't try to be smart with merging. When you merge, if it can merge cleanly, it will do so. If it cannot, it will halt the merge process and mark the conflicts which you should resolve manually.


2 Answers

I found it myself. It was because git on the jenkins server wasn't configured with author name/email.

After configuring this (under additional behaviours) solved the problem.

like image 168
tkarls Avatar answered Sep 22 '22 21:09

tkarls


I also found that this error occurred if Jenkins/git was configured to do a shallow clone. If you are shallow cloning you'll need to disable it:

  1. uncheck "Shallow clone" in "Additional Behaviors -> Advanced clone behaviors" in the job config
  2. blank out the shallow clone depth (or it was still shallow cloning if there was any value here)
  3. delete any workspaces for this job, as it won't "unshallow" the clone, it'll need to re-clone.
like image 31
mrooney Avatar answered Sep 22 '22 21:09

mrooney