-
Bug
-
Resolution: Fixed
-
Minor
-
None
When a merge conflict happens, the git plugin will try to get the BuildData of the Run and mark it as built (and failed) so that it is not built again:
https://github.com/p0deje/git-plugin/blob/master/src/main/java/hudson/plugins/git/extensions/impl/PreBuildMerge.java#L88
However, this BuildData Action does not exist yet on the run! It is a PreMerge, so it hasn't been saved yet. And if it hasn't been saved, scm.getBuildData() will iteratively look in the previous build until it finds something - finding the previous Run (if there is one)
This means that the previous commit's lastBuild is set to the merge conflict revision.
This is important because the BuildData.lastBuild is the authoritative truth on what the Build has built. By corrupting it we're erasing build history of what was built last time around. This is important for my use-case because I'm querying it to update a tag in another job.
I will submit a PR shortly - the fix is to add a new BuildData to the Run if there isn't one under such circumstances.