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

"Merge before build" does not fetch updated merge target

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed (View Workflow)
    • Priority: Minor
    • Resolution: Not A Defect
    • Component/s: git-plugin
    • Labels:
    • Environment:
      Ubuntu 14.04
      Jenkins 2.16
      Git plugin 3.0.1
    • Similar Issues:

      Description

      As part of our pull request workflow, we want Jenkins to try merging the pull request branch with the merge target.  We're using the "Stash pullrequest builder" plugin to poll the repo and provide the branch specifiers for both the pull request branch and the merge target to the Git plugin.

      In the configuration, we get (emphasizing important items):

      • "Branches to build" branch specifier: origin/pr/${pullRequestId}/from
      • "Additional behaviors", "Merge before build" has options:
        • Name of repository: origin
        • Branch to merge to: ${targetBranch}
        • Merge strategy: default
        • Fast-forward mode: --ff

      Unfortunately, while the Git plugin will fetch the item under "Branches to build", it does not fetch the "Branch to merge to", which means that it always merges with the wrong commit after the branch has moved in the upstream repo.

      To work around this, we're using "Wipe out repository and force clone", but it's a clumsy solution that won't scale up for larger repositories.

      One possible way to address the issue: "Merge before build" could automatically fetch the merge target

      Alternate possibility that might be valuable for other uses too: add a new "Additional behavior" that allows fetching specific refs.

      Please let me know if you need any additional information!

        Attachments

          Activity

          Hide
          markewaite Mark Waite added a comment -

          Couldn't you just add the refspec of the target branch to the "Advanced" section of the repository definition so that it will be fetched in addition to the fetch of the pull request?

          Show
          markewaite Mark Waite added a comment - Couldn't you just add the refspec of the target branch to the "Advanced" section of the repository definition so that it will be fetched in addition to the fetch of the pull request?
          Hide
          gregoryfong_vg Gregory Fong added a comment - - edited

          Mark Waite , thanks for the quick response.  I thought that only supported a single refspec because the documentation for that feature didn't suggest otherwise.  However, since you mentioned that, I did a search and see that you updated this documentation in version 3.1.0 of the git plugin.  That'll do nicely, appreciate the help!

          Show
          gregoryfong_vg Gregory Fong added a comment - - edited Mark Waite  , thanks for the quick response.  I thought that only supported a single refspec because the documentation for that feature didn't suggest otherwise.  However, since you mentioned that, I did a search and see that you updated this documentation in version 3.1.0 of the git plugin .  That'll do nicely, appreciate the help!
          Hide
          markewaite Mark Waite added a comment -

          I would love confirmation that the multiple refspec technique worked for you. Good luck

          Show
          markewaite Mark Waite added a comment - I would love confirmation that the multiple refspec technique worked for you. Good luck
          Hide
          gregoryfong_vg Gregory Fong added a comment -

          Confirmed using the console log that it fetched all provided refspecs.

          Show
          gregoryfong_vg Gregory Fong added a comment - Confirmed using the console log that it fetched all provided refspecs.

            People

            • Assignee:
              Unassigned
              Reporter:
              gregoryfong_vg Gregory Fong
            • Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: