tkarls
tkarls

Reputation: 3279

merge before build in jenkins fails but should not

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?

Upvotes: 23

Views: 14677

Answers (4)

Cloud
Cloud

Reputation: 3219

I have multiple projects in Gitlab that using jenkins, but sometimes a project will raise this problem. So I don't think it's because git name or email.

Always, I git pull from the upstream, make sure the local is consistent with the remote, then git commit --amend(you can just quit, don't need to edit it) --> git pull -0> git push --> start jenkins.

Upvotes: 0

mrooney
mrooney

Reputation: 2022

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.

Upvotes: 3

JayS
JayS

Reputation: 2283

I had the same error where it was stuck trying to build a previous branch SHA-1. I removed the branch, it still tried to build the branch SHA-1 and failed the same way. I configured git with author name/email as suggested, but it still failed. I then removed the Jenkins workspace root directory and the error changed to "Could not checkout ...". I then recreated the branch directly from master, uploaded a minor change and created a pull request. Jenkins rebuilt the new branch correctly and began working again. This discusses the "Could not checkout" issue: https://issues.jenkins-ci.org/browse/JENKINS-26748

Upvotes: 0

tkarls
tkarls

Reputation: 3279

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.

Upvotes: 30

Related Questions