# ERROR: Error cloning remote repo 'origin'

**URL:** <https://community.jenkins.io/t/error-error-cloning-remote-repo-origin/8869>\
**Category:** Using Jenkins\
**Tags:** question\
**Created:** [August 7, 2023, 5:36am UTC](https://community.jenkins.io/t/error-error-cloning-remote-repo-origin/8869 "2023-08-07T05:36:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abhi](https://avatars.discourse-cdn.com/v4/letter/a/b487fb/32.png) [@Abhi](https://community.jenkins.io/u/Abhi)\
**Post date:** [August 7, 2023, 5:36am UTC](https://community.jenkins.io/t/error-error-cloning-remote-repo-origin/8869/1 "2023-08-07T05:36:56Z")

</div>

Jenkins setup:  
Version: 2.401.1  
I have a multibranch pipeline with few jenkins stages. Jenkinsfile is kept in a scm repo.  
Jenkins agent is created using ec2 plugin  
Issue:  
Facing an intermittent issue where checkout scm fails with below issue:  
[Pipeline] { (Declarative: Checkout SCM)  
[Pipeline] checkout  
The recommended git tool is: NONE  
using credential xxx  
Cloning the remote Git repository  
Cloning with configured refspecs honoured and without tags  
Cloning repository https:///abc.git

> git init /var/lib/jenkins/workspace/abc\_controller # timeout=10  
> Fetching upstream changes from https:///abc.git  
> git --version # timeout=10  
> git --version # ‘git version 2.39.3’  
> using GIT\_ASKPASS to set credentials Credentials to xxx repository  
> git fetch --no-tags --force --progress – https:///abc.git +refs/heads/controller:refs/remotes/origin/controller # timeout=10  
> ERROR: Error cloning remote repo ‘origin’  
> hudson.plugins.git.GitException: Command “git fetch --no-tags --force --progress – https:///abc.git +refs/heads/controller:refs/remotes/origin/controller” returned status code 1:  
> stdout:  
> stderr: remote: Enumerating objects: 13251  
> remote: Enumerating objects: 18395, done.  
> remote: Counting objects: 0% (1/5144)  
> remote: Counting objects: 1% (52/5144)  
> remote: Counting objects: 2% (103/5144)  
> remote: Counting objects: 3% (155/5144)  
> remote: Counting objects: 4% (206/5144)  
> …  
> …  
> Resolving deltas: 99% (12013/12133)  
> Resolving deltas: 100% (12133/12133)  
> Resolving deltas: 100% (12133/12133), done.  
> error: cannot lock ref ‘refs/remotes/origin/controller’: Unable to create ‘/var/lib/jenkins/workspace/abc\_controller/.git/refs/remotes/origin/controller.lock’: No such file or directory  
> From https:///abc  
> ! [new branch] controller → origin/controller (unable to update local ref)

```
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2842)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2185)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:635)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$2.execute(CliGitAPIImpl.java:871)
at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$GitCommandMasterToSlaveCallable.call(RemoteGitImpl.java:170)
at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$GitCommandMasterToSlaveCallable.call(RemoteGitImpl.java:161)
at hudson.remoting.UserRequest.perform(UserRequest.java:211)
at hudson.remoting.UserRequest.perform(UserRequest.java:54)
at hudson.remoting.Request$2.run(Request.java:377)
at hudson.remoting.InterceptingExecutorService.lambda$wrap$0(InterceptingExecutorService.java:78)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
Suppressed: hudson.remoting.Channel$CallSiteStackTrace: Remote call to EC2 (jenkins-slave) - jenkins-slave (xxx-xxx)
	at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1784)
	at hudson.remoting.UserRequest$ExceptionResponse.retrieve(UserRequest.java:356)
	at hudson.remoting.Channel.call(Channel.java:1000)
	at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler.execute(RemoteGitImpl.java:153)

```

Tried a few solutions:

1. Increased timeout from 10 mins to 20 mins  
Logs-\> Same issue
2. Implement ‘Clean Before Checkout’ with git plugin  
Logs-\>  
org.jenkinsci.plugins.workflow.actions.ErrorAction$ErrorId: xxx org.jenkinsci.plugins.workflow.steps.MissingContextVariableException: Required context class hudson.FilePath is missing Perhaps you forgot to surround the code with a step that provides this, such as: node  
…

org.jenkinsci.plugins.workflow.actions.ErrorAction$ErrorId: xxx Caused: java.io.IOException: Remote call on EC2 (jenkins-agent) - jenkins-agent (xxx) failed

> **Plugin list is here**
>
> Office-365-Connector: 4.18.0  
> ace-editor: 1.1  
> analysis-model-api: 11.2.0  
> ant: 487.vd79d090d4ea\_e  
> antisamy-markup-formatter: 159.v25b\_c67cd35fb\_  
> apache-httpcomponents-client-4-api: 4.5.14-150.v7a\_b\_9d17134a\_5  
> authentication-tokens: 1.53.v1c90fd9191a\_b\_  
> authorize-project: 1.6.0  
> aws-credentials: 191.vcb\_f183ce58b\_9  
> aws-java-sdk-cloudformation: 1.12.481-392.v8b\_291cfcda\_09  
> aws-java-sdk-codebuild: 1.12.481-392.v8b\_291cfcda\_09  
> aws-java-sdk-ec2: 1.12.481-392.v8b\_291cfcda\_09  
> aws-java-sdk-ecr: 1.12.481-392.v8b\_291cfcda\_09  
> aws-java-sdk-ecs: 1.12.481-392.v8b\_291cfcda\_09  
> aws-java-sdk-efs: 1.12.481-392.v8b\_291cfcda\_09  
> aws-java-sdk-elasticbeanstalk: 1.12.481-392.v8b\_291cfcda\_09  
> aws-java-sdk-iam: 1.12.481-392.v8b\_291cfcda\_09  
> aws-java-sdk-kinesis: 1.12.481-392.v8b\_291cfcda\_09  
> aws-java-sdk-logs: 1.12.481-392.v8b\_291cfcda\_09  
> aws-java-sdk-minimal: 1.12.481-392.v8b\_291cfcda\_09  
> aws-java-sdk-sns: 1.12.481-392.v8b\_291cfcda\_09  
> aws-java-sdk-sqs: 1.12.481-392.v8b\_291cfcda\_09  
> aws-java-sdk-ssm: 1.12.481-392.v8b\_291cfcda\_09  
> aws-java-sdk: 1.12.481-392.v8b\_291cfcda\_09  
> aws-parameter-store: 1.2.2  
> badge: 1.9.1  
> blueocean-autofavorite: 1.2.5  
> blueocean-bitbucket-pipeline: 1.27.4  
> blueocean-commons: 1.27.4  
> blueocean-config: 1.27.4  
> blueocean-core-js: 1.27.4  
> blueocean-dashboard: 1.27.4  
> blueocean-display-url: 2.4.2  
> blueocean-events: 1.27.4  
> blueocean-git-pipeline: 1.27.4  
> blueocean-github-pipeline: 1.27.4  
> blueocean-i18n: 1.27.4  
> blueocean-jira: 1.27.4  
> blueocean-jwt: 1.27.4  
> blueocean-personalization: 1.27.4  
> blueocean-pipeline-api-impl: 1.27.4  
> blueocean-pipeline-editor: 1.27.4  
> blueocean-pipeline-scm-api: 1.27.4  
> blueocean-rest-impl: 1.27.4  
> blueocean-rest: 1.27.4  
> blueocean-web: 1.27.4  
> blueocean: 1.27.4  
> bootstrap4-api: 4.6.0-6  
> bootstrap5-api: 5.2.3-1  
> bouncycastle-api: 2.28  
> branch-api: 2.1105.v472604208c55  
> build-user-vars-plugin: 1.9  
> caffeine-api: 3.1.6-115.vb\_8b\_b\_328e59d8  
> checks-api: 2.0.0  
> cloudbees-bitbucket-branch-source: 805.v7f97d29dc0f5  
> cloudbees-disk-usage-simple: 182.v62ca\_0c992a\_f3  
> cloudbees-folder: 6.815.v0dd5a\_cb\_40e0e  
> command-launcher: 100.v2f6722292ee8  
> commons-text-api: 1.10.0-36.vc008c8fcda\_7b\_  
> commons-httpclient3-api: 3.1-3  
> commons-lang3-api: 3.12.0-36.vd97de6465d5b\_  
> configuration-as-code-secret-ssm: 1.0.1  
> configuration-as-code: 1647.ve39ca\_b\_829b\_42  
> credentials-binding: 604.vb\_64480b\_c56ca\_  
> credentials: 1254.vb\_96f366e7b\_a\_d  
> cucumber-reports: 5.7.5  
> cucumber-trends-report: 1.3  
> data-tables-api: 1.13.3-4  
> display-url-api: 2.3.7  
> docker-commons: 419.v8e3cd84ef49c  
> docker-workflow: 563.vd5d2e5c4007f  
> dtkit-api: 3.0.2  
> durable-task: 507.v050055d0cb\_dd  
> ec2: 2.0.7  
> echarts-api: 5.4.0-4  
> email-ext: 2.97  
> extended-read-permission: 3.2  
> external-monitor-job: 203.v683c09d993b\_9  
> favorite: 2.4.2  
> font-awesome-api: 6.3.0-2  
> forensics-api: 2.2.0  
> git-client: 4.3.0  
> git-server: 99.va\_0826a\_b\_cdfa\_d  
> git: 5.0.2  
> github-api: 1.314-431.v78d72a\_3fe4c3  
> github-branch-source: 1725.vd391eef681a\_e  
> github: 1.37.1  
> greenballs: 1.15.1  
> groovy-postbuild: 2.5  
> handlebars: 3.0.8  
> jacoco: 3.3.3  
> handy-uri-templates-2-api: 2.1.8-22.v77d5b\_75e6953  
> htmlpublisher: 1.31  
> instance-identity: 142.v04572ca\_5b\_265  
> ionicons-api: 56.v1b\_1c8c49374e  
> jackson2-api: 2.15.2-350.v0c2f3f8fc595  
> jakarta-activation-api: 2.0.1-3  
> jakarta-mail-api: 2.0.1-3  
> javadoc: 233.vdc1a\_ec702cff  
> javax-activation-api: 1.2.0-6  
> javax-mail-api: 1.6.2-9  
> jaxb: 2.3.8-1  
> jdk-tool: 66.vd8fa\_64ee91b\_d  
> jenkins-design-language: 1.27.4  
> jersey2-api: 2.39.1-2  
> jira: 3.10  
> jjwt-api: 0.11.5-77.v646c772fddb\_0  
> job-dsl: 1.84  
> jquery-detached: 1.2.1  
> jquery3-api: 3.7.0-1  
> jsch: 0.2.8-65.v052c39de79b\_2  
> junit: 1207.va\_09d5100410f  
> ldap: 682.v7b\_544c9d1512  
> lockable-resources: 1156.v5e9f897ece02  
> mailer: 457.v3f72cb\_e015e5  
> mask-passwords: 150.vf80d33113e80  
> matrix-auth: 3.1.8  
> matrix-project: 789.v57a\_725b\_63c79  
> mercurial: 1260.vdfb\_723cdcc81  
> metrics: 4.2.18-438.v0ede325a\_4c68  
> mina-sshd-api-common: 2.10.0-69.v28e3e36d18eb\_  
> mina-sshd-api-core: 2.10.0-69.v28e3e36d18eb\_  
> momentjs: 1.1.1  
> node-iterator-api: 49.v58a\_8b\_35f8363  
> okhttp-api: 4.11.0-145.vcb\_8de402ef81  
> pam-auth: 1.10  
> parameterized-scheduler: 1.2  
> pipeline-build-step: 491.v1fec530da\_858  
> pipeline-graph-analysis: 202.va\_d268e64deb\_3  
> pipeline-groovy-lib: 656.va\_a\_ceeb\_6ffb\_f7  
> pipeline-input-step: 468.va\_5db\_051498a\_4  
> pipeline-milestone-step: 111.v449306f708b\_7  
> pipeline-model-api: 2.2133.ve46a\_6113dfc3  
> pipeline-model-definition: 2.2133.ve46a\_6113dfc3  
> pipeline-model-extensions: 2.2133.ve46a\_6113dfc3  
> pipeline-rest-api: 2.32  
> pipeline-stage-step: 305.ve96d0205c1c6  
> pipeline-stage-tags-metadata: 2.2133.ve46a\_6113dfc3  
> pipeline-stage-view: 2.32  
> pipeline-utility-steps: 2.15.4  
> plain-credentials: 143.v1b\_df8b\_d3b\_e48  
> plugin-util-api: 3.2.1  
> popper-api: 1.16.1-3  
> popper2-api: 2.11.6-2  
> prism-api: 1.29.0-7  
> prometheus: 2.2.3  
> pubsub-light: 1.17  
> rake: 1.8.0  
> rebuild: 320.v5a\_0933a\_e7d61  
> role-strategy: 633.v836e5b\_3e80a\_5  
> saml: 4.418.vdfa\_7489a\_b\_a\_2d  
> scm-api: 672.v64378a\_b\_20c60  
> script-security: 1251.vfe552ed55f8d  
> snakeyaml-api: 1.33-95.va\_b\_a\_e3e47b\_fa\_4  
> snyk-security-scanner: 3.2.7  
> splunk-devops: 1.10.1  
> sse-gateway: 1.26  
> ssh-credentials: 305.v8f4381501156  
> ssh-slaves: 2.877.v365f5eb\_a\_b\_eec  
> sshd: 3.303.vefc7119b\_ec23  
> structs: 324.va\_f5d6774f3a\_d  
> timestamper: 1.25  
> token-macro: 359.vb\_cde11682e0c  
> trilead-api: 2.84.v72119de229b\_7  
> validating-string-parameter: 2.8  
> variant: 59.vf075fe829ccb  
> warnings-ng: 10.2.0  
> windows-slaves: 1.8.1  
> workflow-aggregator: 596.v8c21c963d92d  
> workflow-api: 1213.v646def1087f9  
> workflow-basic-steps: 1017.vb\_45b\_302f0cea\_  
> workflow-cps-global-lib: 609.vd95673f149b\_b  
> workflow-cps: 3673.v5b\_dd74276262  
> workflow-durable-task-step: 1247.v7f9dfea\_b\_4fd0  
> workflow-job: 1308.v58d48a\_763b\_31  
> workflow-multibranch: 746.v05814d19c001  
> workflow-scm-step: 408.v7d5b\_135a\_b\_d49  
> workflow-step-api: 639.v6eca\_cd8c04a\_a\_  
> workflow-support: 839.v35e2736cfd5c  
> xunit: 3.1.2

---

<div class="post-metadata">

**Author:** ![MarkEWaite](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/markewaite/32/20_2.png) [@MarkEWaite](https://community.jenkins.io/u/MarkEWaite)\
**Post date:** [August 7, 2023, 11:54am UTC](https://community.jenkins.io/t/error-error-cloning-remote-repo-origin/8869/2 "2023-08-07T11:54:35Z")

</div>

> [@Abhi](#):
>
> stderr: remote: Enumerating objects: 13251  
> remote: Enumerating objects: 18395, done.  
> remote: Counting objects: 0% (1/5144)  
> remote: Counting objects: 1% (52/5144)  
> remote: Counting objects: 2% (103/5144)  
> remote: Counting objects: 3% (155/5144)  
> remote: Counting objects: 4% (206/5144)  
> …  
> …  
> Resolving deltas: 99% (12013/12133)  
> Resolving deltas: 100% (12133/12133)  
> Resolving deltas: 100% (12133/12133), done.

Those messages indicate that you are cloning a very large git repository. If you create an existing clone on the agent in a location that is separate from the Jenkins agent directory, you can use the git plugin’s support of a reference repository to reduce the git data transfer, the time required to perform the data transfer, and use no more disc space than you are already using for the large repository.

A 10-15 minute video segment is available that describes the different options that are available to better manage very large git repositories. The video segment describes reference repositories, narrow refspecs, shallow clone, large file support, and more.

[![](https://europe1.discourse-cdn.com/flex013/uploads/jenkins/original/2X/b/ba1726796d9e15547afbd19697334299aa3be270.jpeg "Live 15-minute Demos from Jenkins World") ](https://www.youtube.com/watch?v=jBGFjFc6Jf8&t=6434)

> [@Abhi](#):
>
> org.jenkinsci.plugins.workflow.actions.ErrorAction$ErrorId: xxx org.jenkinsci.plugins.workflow.steps.MissingContextVariableException: Required context class hudson.FilePath is missing Perhaps you forgot to surround the code with a step that provides this, such as: node

When I’ve seen that message in the past, there was often a network issue between the controller and the agent. I’ve not found a general purpose solution to that message, though reducing the amount of time that the agent spends cloning the repository may also reduce the occurrence of that message.
