Search code examples
gitjenkinstimeout

Unable to clone Git repository in Jenkins, request timed out


Not sure why Jenkins is unable to fetch the repo from Bitbucket server. I am running Git for Windows in the Jenkins slave. Using latest Jenkins Community LTS edition i.e. 2.107.2. Please see below the error log -

23:39:06 ERROR: Timeout after 10 minutes
23:39:07 ERROR: Error fetching remote repo 'origin'
23:39:07 hudson.plugins.git.GitException: Failed to fetch from https://xxx/stash/xyz.git
23:39:07    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:862)
23:39:07    at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1129)
23:39:07    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1160)
23:39:07    at hudson.scm.SCM.checkout(SCM.java:504)
23:39:07    at hudson.model.AbstractProject.checkout(AbstractProject.java:1208)
23:39:07    at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:574)
23:39:07    at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
23:39:07    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:499)
23:39:07    at hudson.model.Run.execute(Run.java:1727)
23:39:07    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
23:39:07    at hudson.model.ResourceController.execute(ResourceController.java:97)
23:39:07    at hudson.model.Executor.run(Executor.java:429)
23:39:07 Caused by: hudson.plugins.git.GitException: Command "C:\Program Files\Git\bin\git.exe fetch --tags --progress https://xxx/stash/xyz.git +refs/heads/*:refs/remotes/origin/*" returned status code -1:

And more down below -

23:39:07    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1996)
23:39:07    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1715)
23:39:07    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:72)
23:39:07    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:405)
23:39:07    at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$1.call(RemoteGitImpl.java:153)
23:39:07    at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$1.call(RemoteGitImpl.java:146)
23:39:07    at hudson.remoting.UserRequest.perform(UserRequest.java:210)
23:39:07    at hudson.remoting.UserRequest.perform(UserRequest.java:53)
23:39:07    at hudson.remoting.Request$2.run(Request.java:364)
23:39:07    at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
23:39:07    at java.util.concurrent.FutureTask.run(Unknown Source)
23:39:07    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
23:39:07    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
23:39:07    at hudson.remoting.Engine$1$1.run(Engine.java:94)
23:39:07    at java.lang.Thread.run(Unknown Source)
23:39:07    Suppressed: hudson.remoting.Channel$CallSiteStackTrace: Remote call to JNLP4-connect connection from 172.27.137.169/172.27.137.169:64357
23:39:07        at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1737)
23:39:07        at hudson.remoting.UserResponse.retrieve(UserRequest.java:313)
23:39:07        at hudson.remoting.Channel.call(Channel.java:952)
23:39:07        at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler.execute(RemoteGitImpl.java:146)
23:39:07        at sun.reflect.GeneratedMethodAccessor355.invoke(Unknown Source)
23:39:07        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
23:39:07        at java.lang.reflect.Method.invoke(Unknown Source)
23:39:07        at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler.invoke(RemoteGitImpl.java:132)
23:39:07        at com.sun.proxy.$Proxy73.execute(Unknown Source)
23:39:07        at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:860)
23:39:07        at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1129)
23:39:07        at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1160)
23:39:07        at hudson.scm.SCM.checkout(SCM.java:504)
23:39:07        at hudson.model.AbstractProject.checkout(AbstractProject.java:1208)
23:39:07        at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:574)
23:39:07        at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
23:39:07        at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:499)
23:39:07        at hudson.model.Run.execute(Run.java:1727)
23:39:07        at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
23:39:07        at hudson.model.ResourceController.execute(ResourceController.java:97)
23:39:07        at hudson.model.Executor.run(Executor.java:429)

I can clone the repo in the same slave from Git bash. The repository visibility is public. Both the Jenkins master and slave are running on Windows.


Solution

  • The issue was large number of open branches (~170) in Bitbucket. Due to which git operation was timed out. After deleting obsolete branches (~60) it started working.