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

Git plugin: show conflicting files if pre-build merge fails

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Minor Minor
    • git-plugin
    • None

      The pre-build merge feature of the git plugin is really useful - we use it to help minimise the extent to which feature branches drift away from master. However, when the build fails, the message is pretty uninformative - it just says "did not merge cleanly", but that gives no hint as to how unclean the merge was, and how long it might take to fix, and therefore how to prioritise fixing the merge.

      It would be great if Jenkins could report which files were in conflict after a failed merge: that would make it much easier to distinguish between a simple conflict of one or two files, and a major divergence.

      I believe this could be done by parsing the output of the "git merge" command itself - sample output with the relevant part emphasised:

      $ git merge master
      Auto-merging app/controllers/contacts_controller.rb
      Auto-merging app/controllers/widgets_controller.rb
      CONFLICT (content): Merge conflict in app/controllers/widgets_controller.rb
      Removing js/clients/widgets/gadgets.js
      Auto-merging lib/authenticated_system.rb
      Auto-merging spec/controllers/widgets_controller_spec.rb
      Recorded preimage for 'app/controllers/widgets_controller.rb'
      Automatic merge failed; fix conflicts and then commit the result.

      Alternatively, running "git status" after the failed merge should also show the files in conflict in the "Unmerged paths" section, e.g.:

      $ git status
      # On branch wip.cors.phase2
      # Changes to be committed:
      #
      #	modified:   app/controllers/contacts_controller.rb
      #       ... <blah>
      #
      # Unmerged paths:
      #   (use "git add/rm <file>..." as appropriate to mark resolution)
      #
      #	both modified:      app/controllers/widgets_controller.rb
      #
      

          [JENKINS-10718] Git plugin: show conflicting files if pre-build merge fails

          John Gibson added a comment -

          I'd be in favor of simply printing the output of the merge command in the log (or really any command that fails). In my case the merge was failing because the Jenkins user didn't have a git identity configured. I had to login as jenkins and run the command myself to diagnose the issue:

          jenkins@somewhere.invalid $ /usr/bin/git merge 1234567890abcde1234567890abcde1234567890
          *** Please tell me who you are.
          
          Run
          
            git config --global user.email "you@example.com"
            git config --global user.name "Your Name"
          
          to set your account's default identity.
          Omit --global to set the identity only in this repository.
          
          fatal: empty ident  <jenkins@somewhere.invalid> not allowed
          

          John Gibson added a comment - I'd be in favor of simply printing the output of the merge command in the log (or really any command that fails). In my case the merge was failing because the Jenkins user didn't have a git identity configured. I had to login as jenkins and run the command myself to diagnose the issue: jenkins@somewhere.invalid $ /usr/bin/git merge 1234567890abcde1234567890abcde1234567890 *** Please tell me who you are. Run git config --global user.email "you@example.com" git config --global user.name "Your Name" to set your account's default identity. Omit --global to set the identity only in this repository. fatal: empty ident <jenkins@somewhere.invalid> not allowed

            Unassigned Unassigned
            samstokes Sam Stokes
            Votes:
            3 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: