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

  • How to get rid of dependency errors loading jenkins?
  • Get hudson to checkout source to a specific directory
  • Travis CI with SSHpass to remote pull git modifications
  • Can't su to user jenkins after installing Jenkins
  • Marking upstream Jenkins/Hudson as failed if downstream job fails
  • How to handle username/passwords at continuous integration environment with Jenkins, Git and Gradle?
  • 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?

  • Can I make “git gui” pass, say, “--patience” to “git diff”?
  • Starting with Git: How can I set the directory to work in?
  • Is it possible to see a remote's remotes in git?
  • Can git submodule update be made to fetch tags in submodules?
  • How integrate Selenium Grid 2 With Hudson/Jenkins?
  • How to get an Ansible check to run only once in a playbook?
  • 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: https://issues.jenkins-ci.org/browse/JENKINS-26748

    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.