Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-44037

A merge conflict in PreBuildMerge will corrupt BuildData history in previous builds

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • git-plugin
    • 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)

      https://github.com/jenkinsci/git-plugin/blob/master/src/main/java/hudson/plugins/git/GitSCM.java#L1689

      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.

       

            Unassigned Unassigned
            dalvizu Dan Alvizu
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: