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

Reference build is wrong for PRs

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • git-forensics-plugin
    • None

      The discoverGitReferenceBuild step appears to discover the build in the reference job that includes the last common commit to the branch. This doesn't make sense for PR builds though, since they are merged with the head of the target branch, which means the more appropriate build for comparing metrics against is usually going to be the most recent build of the reference job.

      Reproduce Steps:

      • Create a new git repo
      • Add s single commit, with a Jenkinsfile that checks out the code and runs the discoverGitReferenceBuild step
      • Create a multibranch pipeline job in Jenkins for the new repository and build the main branch
      • Create a new branch. Add one commit (maybe updating the Jenkinsfile to specify main as the defaultBranch - not sure if that's supposed to be automatic, but I've always had to set it to env.CHANGE_TARGET in my tests)
      • Check out the main branch and commit another change.
      • Create a PR from the branch to main
      • Rescan the repository
      • Build main again (so now there should be two builds of main, and a PR with no builds)
      • Build the PR

      The logs will indicate that the PR was merged against the latest commit of main, but the reference build was build #1 of main.

       

      I'm calling this one "major" only because I'm pretty sure the publishCoverage step in an older Jenkins used to handle this before it used git-forensics, and I haven't figured out a workaround yet. (although admittedly I didn't actually test this specific combination when I was experimenting coverage diffs in multibranch pipelines in Jenkins a year ago - I only thought to test this after I read the code while tracking down the other bug I filed)

            drulli Ulli Hafner
            cetlan Christopher
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: