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?

  • Why is Jenkins getting Authentication Failed error for git submodule update?
  • Integrating codecommit with jenkins running on EC2
  • Windows, Git and Jenkins
  • How to see that Jenkins polled a Git repo
  • Package contains object and package with same name
  • Pre-Defined parameters no longer passed to child job
  • Jenkins git submodule update fails
  • How can I tell how long a Jenkins job has been in the wait queue?
  • 4 Solutions collect form web for “merge before build in jenkins fails but should not”

    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.

    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:

    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.

    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.

    Git Baby is a git and github fan, let's start git clone.