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

git submodule fetch fails due to unpruned branch

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • git-plugin
    • None

      If a branch (e.g. a/b) has replaced by a branch that includes a directory (e.g. a/b/c), fetch fails with the following message:

      '''
      FATAL: Command "/usr/bin/git submodule update --init --recursive" returned status code 1:
      [...]
      error: some local refs could not be updated; try running
      'git remote prune origin' to remove any old, conflicting branches
      Unable to fetch in submodule [...]
      '''

      To fix the issue, 'git prune' should include submodules and be run before fetching.

          [JENKINS-13946] git submodule fetch fails due to unpruned branch

          I have this problem too. Below is the full redacted log

          using GIT_SSH to set credentials Jenkins User
          > git ls-remote -h ssh://git@source.com/repo.git # timeout=10
          Fetching upstream changes from origin
          > git config --get remote.origin.url # timeout=10
          using GIT_SSH to set credentials Jenkins User
          > git fetch --tags --progress origin +refs/heads/:refs/remotes/origin/ --prune
          ERROR: [Mon Jun 17 09:16:50 EEST 2019] Could not fetch branches from source afb3187b-38bf-426f-bc1e-0ff04519b1ce
          hudson.plugins.git.GitException: Command "git fetch --tags --progress origin +refs/heads/:refs/remotes/origin/ --prune" returned status code 1:
          stdout:
          stderr: error: there are still refs under 'refs/remotes/origin/Name/ISSUE-123'
          From ssh://git@source.com/repo.git
          ! [new branch] Name/ISSUE-123 -> origin/Name/ISSUE-123 (unable to update local ref)

          at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2042)
          at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1761)
          at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$400(CliGitAPIImpl.java:72)
          at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:442)
          at jenkins.plugins.git.AbstractGitSCMSource$8.run(AbstractGitSCMSource.java:575)
          at jenkins.plugins.git.AbstractGitSCMSource$8.run(AbstractGitSCMSource.java:556)
          at jenkins.plugins.git.AbstractGitSCMSource.doRetrieve(AbstractGitSCMSource.java:367)
          at jenkins.plugins.git.AbstractGitSCMSource.retrieve(AbstractGitSCMSource.java:556)
          at jenkins.scm.api.SCMSource._retrieve(SCMSource.java:373)
          at jenkins.scm.api.SCMSource.fetch(SCMSource.java:283)
          at jenkins.branch.MultiBranchProject.computeChildren(MultiBranchProject.java:634)
          at com.cloudbees.hudson.plugins.folder.computed.ComputedFolder.updateChildren(ComputedFolder.java:277)
          at com.cloudbees.hudson.plugins.folder.computed.FolderComputation.run(FolderComputation.java:164)
          at jenkins.branch.MultiBranchProject$BranchIndexing.run(MultiBranchProject.java:1025)
          at hudson.model.ResourceController.execute(ResourceController.java:97)
          at hudson.model.Executor.run(Executor.java:429)
          [Mon Jun 17 09:16:50 EEST 2019] Finished branch indexing. Indexing took 0.45 sec
          FATAL: Failed to recompute children of smc-main
          hudson.plugins.git.GitException: Command "git fetch --tags --progress origin +refs/heads/:refs/remotes/origin/ --prune" returned status code 1:
          stdout:
          stderr: error: there are still refs under 'refs/remotes/origin/Name/ISSUE-123'
          From ssh://source.com/repo
          ! [new branch] Name/ISSUE-123 -> origin/Name/ISSUE-123 (unable to update local ref)

          at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2042)
          at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1761)
          at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$400(CliGitAPIImpl.java:72)
          at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:442)
          at jenkins.plugins.git.AbstractGitSCMSource$8.run(AbstractGitSCMSource.java:575)
          at jenkins.plugins.git.AbstractGitSCMSource$8.run(AbstractGitSCMSource.java:556)
          at jenkins.plugins.git.AbstractGitSCMSource.doRetrieve(AbstractGitSCMSource.java:367)
          at jenkins.plugins.git.AbstractGitSCMSource.retrieve(AbstractGitSCMSource.java:556)
          at jenkins.scm.api.SCMSource._retrieve(SCMSource.java:373)
          at jenkins.scm.api.SCMSource.fetch(SCMSource.java:283)
          at jenkins.branch.MultiBranchProject.computeChildren(MultiBranchProject.java:634)
          at com.cloudbees.hudson.plugins.folder.computed.ComputedFolder.updateChildren(ComputedFolder.java:277)
          at com.cloudbees.hudson.plugins.folder.computed.FolderComputation.run(FolderComputation.java:164)
          at jenkins.branch.MultiBranchProject$BranchIndexing.run(MultiBranchProject.java:1025)
          at hudson.model.ResourceController.execute(ResourceController.java:97)
          at hudson.model.Executor.run(Executor.java:429)
          Finished: FAILURE

          Adding "Prune stale remote-tracking branches" behaviour in the job config does not help with this. What needs to be done when this stage is reached, the Jenkins master Git cache needs to be deleted. It is in "caches" folder in the Jenkins workspace.

          Lasse Lindqvist added a comment - I have this problem too. Below is the full redacted log using GIT_SSH to set credentials Jenkins User > git ls-remote -h ssh://git@source.com/repo.git # timeout=10 Fetching upstream changes from origin > git config --get remote.origin.url # timeout=10 using GIT_SSH to set credentials Jenkins User > git fetch --tags --progress origin +refs/heads/ :refs/remotes/origin/ --prune ERROR: [Mon Jun 17 09:16:50 EEST 2019] Could not fetch branches from source afb3187b-38bf-426f-bc1e-0ff04519b1ce hudson.plugins.git.GitException: Command "git fetch --tags --progress origin +refs/heads/ :refs/remotes/origin/ --prune" returned status code 1: stdout: stderr: error: there are still refs under 'refs/remotes/origin/Name/ISSUE-123' From ssh://git@source.com/repo.git ! [new branch] Name/ISSUE-123 -> origin/Name/ISSUE-123 (unable to update local ref) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2042) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1761) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$400(CliGitAPIImpl.java:72) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:442) at jenkins.plugins.git.AbstractGitSCMSource$8.run(AbstractGitSCMSource.java:575) at jenkins.plugins.git.AbstractGitSCMSource$8.run(AbstractGitSCMSource.java:556) at jenkins.plugins.git.AbstractGitSCMSource.doRetrieve(AbstractGitSCMSource.java:367) at jenkins.plugins.git.AbstractGitSCMSource.retrieve(AbstractGitSCMSource.java:556) at jenkins.scm.api.SCMSource._retrieve(SCMSource.java:373) at jenkins.scm.api.SCMSource.fetch(SCMSource.java:283) at jenkins.branch.MultiBranchProject.computeChildren(MultiBranchProject.java:634) at com.cloudbees.hudson.plugins.folder.computed.ComputedFolder.updateChildren(ComputedFolder.java:277) at com.cloudbees.hudson.plugins.folder.computed.FolderComputation.run(FolderComputation.java:164) at jenkins.branch.MultiBranchProject$BranchIndexing.run(MultiBranchProject.java:1025) at hudson.model.ResourceController.execute(ResourceController.java:97) at hudson.model.Executor.run(Executor.java:429) [Mon Jun 17 09:16:50 EEST 2019] Finished branch indexing. Indexing took 0.45 sec FATAL: Failed to recompute children of smc-main hudson.plugins.git.GitException: Command "git fetch --tags --progress origin +refs/heads/ :refs/remotes/origin/ --prune" returned status code 1: stdout: stderr: error: there are still refs under 'refs/remotes/origin/Name/ISSUE-123' From ssh://source.com/repo ! [new branch] Name/ISSUE-123 -> origin/Name/ISSUE-123 (unable to update local ref) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2042) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1761) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$400(CliGitAPIImpl.java:72) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:442) at jenkins.plugins.git.AbstractGitSCMSource$8.run(AbstractGitSCMSource.java:575) at jenkins.plugins.git.AbstractGitSCMSource$8.run(AbstractGitSCMSource.java:556) at jenkins.plugins.git.AbstractGitSCMSource.doRetrieve(AbstractGitSCMSource.java:367) at jenkins.plugins.git.AbstractGitSCMSource.retrieve(AbstractGitSCMSource.java:556) at jenkins.scm.api.SCMSource._retrieve(SCMSource.java:373) at jenkins.scm.api.SCMSource.fetch(SCMSource.java:283) at jenkins.branch.MultiBranchProject.computeChildren(MultiBranchProject.java:634) at com.cloudbees.hudson.plugins.folder.computed.ComputedFolder.updateChildren(ComputedFolder.java:277) at com.cloudbees.hudson.plugins.folder.computed.FolderComputation.run(FolderComputation.java:164) at jenkins.branch.MultiBranchProject$BranchIndexing.run(MultiBranchProject.java:1025) at hudson.model.ResourceController.execute(ResourceController.java:97) at hudson.model.Executor.run(Executor.java:429) Finished: FAILURE Adding "Prune stale remote-tracking branches" behaviour in the job config does not help with this. What needs to be done when this stage is reached, the Jenkins master Git cache needs to be deleted. It is in "caches" folder in the Jenkins workspace.

            Unassigned Unassigned
            sprohaska Steffen Prohaska
            Votes:
            3 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: