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

"reference is not a tree" when doing a git checkout of the commit being built

XMLWordPrintable

      Frequently (very roughly 20% of the time in our case), when checking out a PR to be built, Jenkins correctly determines the ref to be built, fails to fetch that ref, but attempts to checkout that ref anyway:

      Branch indexing
      Checking out git ssh://git@my.bitbucket.server:7999/SC/cub_policy_osr_atlas.git ssh://git@my.bitbucket.server:7999/SC/cub_policy_osr_atlas.git to read Jenkinsfile
      Wiping out workspace first.
      Cloning the remote Git repository
      Cloning with configured refspecs honoured and without tags
      Cloning repository ssh://git@my.bitbucket.server:7999/SC/cub_policy_osr_atlas.git
       > git init /var/lib/jenkins/jobs/sis_configuration_management/jobs/cub-policy-osr-atlas.59lagq/branches/PR-2/workspace@script # timeout=10
      Fetching upstream changes from ssh://git@my.bitbucket.server:7999/SC/cub_policy_osr_atlas.git
       > git --version # timeout=10
      using GIT_SSH to set credentials Credentials for jenkins - created by Chef
       > git fetch --no-tags --progress ssh://git@my.bitbucket.server:7999/SC/cub_policy_osr_atlas.git +refs/pull-requests/2/from:refs/remotes/origin/PR-2
       > git config remote.origin.url ssh://git@my.bitbucket.server:7999/SC/cub_policy_osr_atlas.git # timeout=10
       > git config --add remote.origin.fetch +refs/pull-requests/2/from:refs/remotes/origin/PR-2 # timeout=10
       > git config remote.origin.url ssh://git@my.bitbucket.server:7999/SC/cub_policy_osr_atlas.git # timeout=10
      Fetching without tags
      Fetching upstream changes from ssh://git@my.bitbucket.server:7999/SC/cub_policy_osr_atlas.git
      using GIT_SSH to set credentials Credentials for jenkins - created by Chef
       > git fetch --no-tags --progress ssh://git@my.bitbucket.server:7999/SC/cub_policy_osr_atlas.git +refs/pull-requests/2/from:refs/remotes/origin/PR-2
       > git config remote.upstream.url ssh://git@my.bitbucket.server:7999/SC/cub_policy_osr_atlas.git # timeout=10
      Fetching without tags
      Fetching upstream changes from ssh://git@my.bitbucket.server:7999/SC/cub_policy_osr_atlas.git
      using GIT_SSH to set credentials Credentials for jenkins - created by Chef
       > git fetch --no-tags --progress ssh://git@my.bitbucket.server:7999/SC/cub_policy_osr_atlas.git +refs/heads/master:refs/remotes/upstream/master
      Merging remotes/upstream/master commit 65f8ec3e639b1a725770e0e479ea99a4bcc8d5dd into PR head commit 6a3034de8ab6d795397d38ed1aeca39c1614521e
       > git config core.sparsecheckout # timeout=10
       > git checkout -f 6a3034de8ab6d795397d38ed1aeca39c1614521e
      [Bitbucket] Notifying pull request build result
      [Bitbucket] Build result notified
      hudson.plugins.git.GitException: Command "git checkout -f 6a3034de8ab6d795397d38ed1aeca39c1614521e" returned status code 128:
      stdout: 
      stderr: fatal: reference is not a tree: 6a3034de8ab6d795397d38ed1aeca39c1614521e
      
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1903)
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$800(CliGitAPIImpl.java:71)
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$9.execute(CliGitAPIImpl.java:2188)
      Caused: hudson.plugins.git.GitException: Could not checkout 6a3034de8ab6d795397d38ed1aeca39c1614521e
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$9.execute(CliGitAPIImpl.java:2211)
      	at com.cloudbees.jenkins.plugins.bitbucket.MergeWithGitSCMExtension.checkout(MergeWithGitSCMExtension.java:126)
      	at com.cloudbees.jenkins.plugins.bitbucket.MergeWithGitSCMExtension.decorateRevisionToBuild(MergeWithGitSCMExtension.java:94)
      	at hudson.plugins.git.GitSCM.determineRevisionToBuild(GitSCM.java:1023)
      	at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1116)
      	at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:113)
      	at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:130)
      	at org.jenkinsci.plugins.workflow.multibranch.SCMBinder.create(SCMBinder.java:120)
      	at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:262)
      	at hudson.model.ResourceController.execute(ResourceController.java:97)
      	at hudson.model.Executor.run(Executor.java:405)
      Finished: FAILURE
      

      I am not really sure why Jenkins fails to fetch the ref in question. I'm looking into it right now and I'll update this ticket with more details if I learn anything. About all I've been able to figure out so far is that cd-ing into the workspace and running something like git ls-remote and git fetch origin +refs/pull-requests/2/from:refs/remotes/origin/PR-2 seems to resolve the issues with the repo.

      Usually, running the job again fixes the error. Occasionally, we'll get two or three failures in a row, which is quite annoying, but spamming the build button will eventually result in a successful build.

            Unassigned Unassigned
            jay_hendren jay hendren
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: