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

Reference build discovery doesn't work if added to old existing projects

XMLWordPrintable

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

      Because of the way the find reference build loop is written, it fails to find a reference build if the git forensics is added  to a project (for example, converting a legacy project to a pipeline) if there are enough commits in repository, even if an appropriate reference build is the HEAD of the reference branch.

      The culprit is the getReferencePoint function, because the loop starts with the commit list initialized to the reference job's latest commits - which will be all of them on the first build, and if there are enough the loop won't even run once.

      Reproduce steps:

      • Create a new git repository
      • Add a Jenkinsfile script that checks out the branch (checkout scm), and uses discoverGitReferenceBuild
      • Add over 100 commits to the repository
      • Create a new branch off the HEAD
      • Create a new multibranch pipeline job in Jenkins for the repository
      • Build the mainline
      • Build the branch

      I have created a repository https://github.com/Cetlan/git-forensics-bug that takes care of the first four steps.

      The logs for the branch build should indicate that no reference build was found, even though the appropriate reference build should be the only build and the common commit should be the most recent commit in that branch)

      "Workaround":

      Set maxCommits to at least the number of commits in the longest branch that could be needed for a reference branch, at least until all branches/PRs are based on commits that are in "smaller" builds.

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

              Created:
              Updated:
              Resolved: