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
- Jenkins: running build does not provision docker slave
- How to change home directory of Jenkins?
- “aapt” IOException error=2, No such file or directory" why can't I build my gradle on jenkins?
- Update Git repository of a jenkins jobs using rest
- Maven Release Plugin use in Jenkins Pipeline
- Trigger build only on pushes to master
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?
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:
- uncheck “Shallow clone” in “Additional Behaviors -> Advanced clone behaviors” in the job config
- blank out the shallow clone depth (or it was still shallow cloning if there was any value here)
- 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 –>