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

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

    Details

    • Similar Issues:

      Description

      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.

       

        Attachments

          Activity

          Show
          dalvizu Dan Alvizu added a comment - https://github.com/jenkinsci/git-plugin/pull/493
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Dan Alvizu
          Path:
          src/main/java/hudson/plugins/git/extensions/impl/PreBuildMerge.java
          src/test/java/hudson/plugins/git/extensions/GitSCMExtensionTest.java
          src/test/java/hudson/plugins/git/extensions/impl/PreBuildMergeTest.java
          http://jenkins-ci.org/commit/git-plugin/6b9bb1b0457878105abe200fe7705ba95e76acb6
          Log:
          [Fixed JENKINS-44037] Add a new `BuildData` action if PreBuildMerge fails

          This fixes a buggy behavior where BuildData from the previous Run is
          used instead, which corrupts build history.

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Dan Alvizu Path: src/main/java/hudson/plugins/git/extensions/impl/PreBuildMerge.java src/test/java/hudson/plugins/git/extensions/GitSCMExtensionTest.java src/test/java/hudson/plugins/git/extensions/impl/PreBuildMergeTest.java http://jenkins-ci.org/commit/git-plugin/6b9bb1b0457878105abe200fe7705ba95e76acb6 Log: [Fixed JENKINS-44037] Add a new `BuildData` action if PreBuildMerge fails This fixes a buggy behavior where BuildData from the previous Run is used instead, which corrupts build history.
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Dan Alvizu
          Path:
          README.md
          src/main/java/hudson/plugins/git/extensions/impl/PreBuildMerge.java
          src/test/java/hudson/plugins/git/extensions/GitSCMExtensionTest.java
          src/test/java/hudson/plugins/git/extensions/impl/PreBuildMergeTest.java
          http://jenkins-ci.org/commit/git-plugin/d5cc48da1f2b72cb1814af95729cb6ca43327b38
          Log:
          Merge pull request #493 from dalvizu/master

          [Fixed JENKINS-44037] Add a new `BuildData` action if PreBuildMerge fails

          Compare: https://github.com/jenkinsci/git-plugin/compare/686b5ca85527...d5cc48da1f2b

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Dan Alvizu Path: README.md src/main/java/hudson/plugins/git/extensions/impl/PreBuildMerge.java src/test/java/hudson/plugins/git/extensions/GitSCMExtensionTest.java src/test/java/hudson/plugins/git/extensions/impl/PreBuildMergeTest.java http://jenkins-ci.org/commit/git-plugin/d5cc48da1f2b72cb1814af95729cb6ca43327b38 Log: Merge pull request #493 from dalvizu/master [Fixed JENKINS-44037] Add a new `BuildData` action if PreBuildMerge fails Compare: https://github.com/jenkinsci/git-plugin/compare/686b5ca85527...d5cc48da1f2b
          Hide
          markewaite Mark Waite added a comment -

          Fixed in git plugin 3.6.1

          Show
          markewaite Mark Waite added a comment - Fixed in git plugin 3.6.1

            People

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

              Dates

              • Created:
                Updated:
                Resolved: