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

discoverGitReferenceBuild always reports "no reference build found"

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • git-forensics-plugin
    • None
    • Jenkins 2.479.1; Git Forensics Plugin 2.2.1

      I've added discoverGitReferenceBuild to a multibranch pipeline pulling from a git repository 'demo' in Bitbucket Server. My branch is 'enable-reference-build', so it's using itself as a reference.

      pipeline {
        agent any;
        stages {
          stage('Reference') {
            steps {
              discoverGitReferenceBuild referenceJob: 'demo/enable-reference-build'
            }
          }
        }
      }
      

      When I build this pipeline, it reports

      Configured reference job: 'demo/enable-reference-build'
      -> selected build '#5' of reference job does not yet contain a `GitCommitsRecord`
      -> no reference build found
      No reference build with required status found that contains matching commits
      

      The branch has 6 commits, well under maxCommits, so I don't think this is related to JENKINS-66479. I get the same message with referenceJob: main. Enabling latestBuildIfNotFound allows it to fallback to the latest build, but subsequent builds continue to report the warning:

      Configured reference job: 'demo/enable-reference-build'
      -> selected build '#7' of reference job does not yet contain a `GitCommitsRecord`
      -> no reference build found
      No reference build with required status found that contains matching commits
      Falling back to latest completed build of reference job: '#7'
      

          [JENKINS-74921] discoverGitReferenceBuild always reports "no reference build found"

          This might just be a configuration error on my end, but I thought it was worth reporting as I couldn't find any references to the error message in documentation or Jira.

          The Forensics API's discoverReferenceBuild referenceJob: 'demo/main', requiredResult: Result.SUCCESS works as expected, so I'm using that instead:

          Configured reference job: 'demo/main'
          Found last completed build '#2017' of reference job 'main'
          -> Previous build '#2008' has a result SUCCESS

          Patrick Conley added a comment - This might just be a configuration error on my end, but I thought it was worth reporting as I couldn't find any references to the error message in documentation or Jira. The Forensics API's discoverReferenceBuild referenceJob: 'demo/main', requiredResult: Result.SUCCESS works as expected, so I'm using that instead: Configured reference job: 'demo/main' Found last completed build '#2017' of reference job 'main' -> Previous build '#2008' has a result SUCCESS

          Ulli Hafner added a comment - - edited

          The message selected build '#5' of reference job does not yet contain a `GitCommitsRecord` indicates that in the reference build there are no recorded Git Commits yet. Is it possible, that you installed the Git forensics plugin after the last build of the reference job? The recording of Git Commits automatically starts by SCM events, can you check the console if these events are correctly triggered in your reference job? You should get something like:

          ```
          [Pipeline] checkout
          [2024-11-21T18:41:53.087Z] using credential app-ci.jenkins.io
          [2024-11-21T18:41:53.092Z] Cloning the remote Git repository
          [2024-11-21T18:41:53.092Z] Cloning with configured refspecs honoured and without tags
          [2024-11-21T18:41:53.022Z] Cloning repository https://github.com/jenkinsci/warnings-ng-plugin.git
          [2024-11-21T18:41:53.500Z] > git init /home/jenkins/agent/workspace/Plugins_warnings-ng-plugin_main # timeout=10
          [2024-11-21T18:41:53.965Z] Fetching upstream changes from https://github.com/jenkinsci/warnings-ng-plugin.git
          [2024-11-21T18:41:53.965Z] > git --version # timeout=10
          [2024-11-21T18:41:53.970Z] > git --version # 'git version 2.47.0'
          [2024-11-21T18:41:53.971Z] using GIT_ASKPASS to set credentials ci.jenkins.io GitHub App (jenkinsci org)
          [2024-11-21T18:41:53.986Z] > git fetch --no-tags --force --progress – https://github.com/jenkinsci/warnings-ng-plugin.git +refs/heads/main:refs/remotes/origin/main # timeout=10
          [2024-11-21T18:41:56.729Z] Avoid second fetch
          [2024-11-21T18:41:56.729Z] Checking out Revision c9a115a72d2611aaefdd8559b5b1570be844470b (main)
          [2024-11-21T18:41:56.416Z] > git config remote.origin.url https://github.com/jenkinsci/warnings-ng-plugin.git # timeout=10
          [2024-11-21T18:41:56.421Z] > git config --add remote.origin.fetch +refs/heads/main:refs/remotes/origin/main # timeout=10
          [2024-11-21T18:41:56.650Z] > git config core.sparsecheckout # timeout=10
          [2024-11-21T18:41:56.657Z] > git checkout -f c9a115a72d2611aaefdd8559b5b1570be844470b # timeout=10
          [2024-11-21T18:41:57.042Z] Commit message: "Merge pull request #1895 from jenkinsci/dependabot/github_actions/codecov/codecov-action-5.0.7"
          [2024-11-21T18:41:56.960Z] > git rev-list --no-walk 359f9623b2632b2ffab921302556f146e61a5487 # timeout=10
          [2024-11-21T18:41:57.715Z] [GitHub Checks] GitHub check (name: Jenkins, status: in_progress) has been published.
          [2024-11-21T18:41:57.724Z] using credential app-ci.jenkins.io
          [2024-11-21T18:41:57.740Z] using credential app-ci.jenkins.io
          [2024-11-21T18:41:57.644Z] > git rev-parse HEAD^

          {commit}

          # timeout=10
          [2024-11-21T18:42:00.829Z] [GitCheckoutListener] Recording commits of 'git https://github.com/jenkinsci/warnings-ng-plugin.git'
          [2024-11-21T18:42:00.829Z] [GitCheckoutListener] Found previous build 'Plugins/warnings-ng-plugin/main #208' that contains recorded Git commits
          [2024-11-21T18:42:00.829Z] [GitCheckoutListener] -> Starting recording of new commits since '359f962'
          [2024-11-21T18:42:00.829Z] [GitCheckoutListener] -> Multiple parent commits found - storing latest commit of local merge 'c9a115a'
          [2024-11-21T18:42:00.829Z] [GitCheckoutListener] -> Using parent commit '0f5b502' of local merge as starting point
          [2024-11-21T18:42:00.829Z] [GitCheckoutListener] -> Storing target branch head 'fce0bb4' (second parent of local merge)
          [2024-11-21T18:42:00.829Z] [GitCheckoutListener] -> Recorded 2 new commits
          [2024-11-21T18:42:00.829Z] [GitCheckoutListener] -> The latest commit 'c9a115a72d2611aaefdd8559b5b1570be844470b' is a merge commit
          [2024-11-21T18:42:00.829Z] [GitCheckoutListener] -> Git commit decorator successfully obtained 'hudson.plugins.git.browser.GithubWeb@1aadfa31' to render commit links
          ```

          Ulli Hafner added a comment - - edited The message selected build '#5' of reference job does not yet contain a `GitCommitsRecord` indicates that in the reference build there are no recorded Git Commits yet. Is it possible, that you installed the Git forensics plugin after the last build of the reference job? The recording of Git Commits automatically starts by SCM events, can you check the console if these events are correctly triggered in your reference job? You should get something like: ``` [Pipeline] checkout [2024-11-21T18:41:53.087Z] using credential app-ci.jenkins.io [2024-11-21T18:41:53.092Z] Cloning the remote Git repository [2024-11-21T18:41:53.092Z] Cloning with configured refspecs honoured and without tags [2024-11-21T18:41:53.022Z] Cloning repository https://github.com/jenkinsci/warnings-ng-plugin.git [2024-11-21T18:41:53.500Z] > git init /home/jenkins/agent/workspace/Plugins_warnings-ng-plugin_main # timeout=10 [2024-11-21T18:41:53.965Z] Fetching upstream changes from https://github.com/jenkinsci/warnings-ng-plugin.git [2024-11-21T18:41:53.965Z] > git --version # timeout=10 [2024-11-21T18:41:53.970Z] > git --version # 'git version 2.47.0' [2024-11-21T18:41:53.971Z] using GIT_ASKPASS to set credentials ci.jenkins.io GitHub App (jenkinsci org) [2024-11-21T18:41:53.986Z] > git fetch --no-tags --force --progress – https://github.com/jenkinsci/warnings-ng-plugin.git +refs/heads/main:refs/remotes/origin/main # timeout=10 [2024-11-21T18:41:56.729Z] Avoid second fetch [2024-11-21T18:41:56.729Z] Checking out Revision c9a115a72d2611aaefdd8559b5b1570be844470b (main) [2024-11-21T18:41:56.416Z] > git config remote.origin.url https://github.com/jenkinsci/warnings-ng-plugin.git # timeout=10 [2024-11-21T18:41:56.421Z] > git config --add remote.origin.fetch +refs/heads/main:refs/remotes/origin/main # timeout=10 [2024-11-21T18:41:56.650Z] > git config core.sparsecheckout # timeout=10 [2024-11-21T18:41:56.657Z] > git checkout -f c9a115a72d2611aaefdd8559b5b1570be844470b # timeout=10 [2024-11-21T18:41:57.042Z] Commit message: "Merge pull request #1895 from jenkinsci/dependabot/github_actions/codecov/codecov-action-5.0.7" [2024-11-21T18:41:56.960Z] > git rev-list --no-walk 359f9623b2632b2ffab921302556f146e61a5487 # timeout=10 [2024-11-21T18:41:57.715Z] [GitHub Checks] GitHub check (name: Jenkins, status: in_progress) has been published. [2024-11-21T18:41:57.724Z] using credential app-ci.jenkins.io [2024-11-21T18:41:57.740Z] using credential app-ci.jenkins.io [2024-11-21T18:41:57.644Z] > git rev-parse HEAD^ {commit} # timeout=10 [2024-11-21T18:42:00.829Z] [GitCheckoutListener] Recording commits of 'git https://github.com/jenkinsci/warnings-ng-plugin.git ' [2024-11-21T18:42:00.829Z] [GitCheckoutListener] Found previous build 'Plugins/warnings-ng-plugin/main #208' that contains recorded Git commits [2024-11-21T18:42:00.829Z] [GitCheckoutListener] -> Starting recording of new commits since '359f962' [2024-11-21T18:42:00.829Z] [GitCheckoutListener] -> Multiple parent commits found - storing latest commit of local merge 'c9a115a' [2024-11-21T18:42:00.829Z] [GitCheckoutListener] -> Using parent commit '0f5b502' of local merge as starting point [2024-11-21T18:42:00.829Z] [GitCheckoutListener] -> Storing target branch head 'fce0bb4' (second parent of local merge) [2024-11-21T18:42:00.829Z] [GitCheckoutListener] -> Recorded 2 new commits [2024-11-21T18:42:00.829Z] [GitCheckoutListener] -> The latest commit 'c9a115a72d2611aaefdd8559b5b1570be844470b' is a merge commit [2024-11-21T18:42:00.829Z] [GitCheckoutListener] -> Git commit decorator successfully obtained 'hudson.plugins.git.browser.GithubWeb@1aadfa31' to render commit links ```

          The git forensics plugin has been installed for a few months, but my checkout logs

          [GitCheckoutListener] Skipping issues blame since Git has been configured with shallow clone

          and I do have the repository configured to do a shallow clone with a depth of 1.

          Is the forensiscs plugin completely incompatible with shallow clones, or does it just require a larger depth? I can play around and find out.

          Patrick Conley added a comment - The git forensics plugin has been installed for a few months, but my checkout logs [GitCheckoutListener] Skipping issues blame since Git has been configured with shallow clone and I do have the repository configured to do a shallow clone with a depth of 1. Is the forensiscs plugin completely incompatible with shallow clones, or does it just require a larger depth? I can play around and find out.

            drulli Ulli Hafner
            pconley Patrick Conley
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: