GitException File Name Too Long

Issue

Git exception: Filename too long during checkout

A git checkout fails with an exception similar to:

```
Checking out Revision xxx

hudson.plugins.git.GitException: Could not checkout xxx
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$9.execute(CliGitAPIImpl.java:2005)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1124)
at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:109)
at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:108)
at org.jenkinsci.plugins.workflow.multibranch.SCMBinder.create(SCMBinder.java:85)
at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:207)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:410)
Caused by: hudson.plugins.git.GitException: xxxx checkout -f xxx returned status code 128:
stdout:
stderr: fatal: cannot create directory at ‘xxxx’: Filename too long
```

Environment

CloudBees Jenkins Enterprise

Jenkins

Resolution

In order for Git to handle long filenames correctly, core.longpaths=true needs to be enabled.

To set this argument you can do the following:

git config --global core.longpaths true

Have more questions? Submit a request

3 Comments

  • 0
    Avatar
    Utp Team

    Where should the above setting be configured? Which location does git plugin from Jenkins read to get the config settings ?

     

  • 0
    Avatar
    Denys Digtiar

    Hi Utp Team,

    By default, Git Plugin uses the native git CLI. Therefore, if you run the command on the Agent using the same git as Jenkins configure to use, it will be written in a right config file and should be picked up from Jenkins.

  • 0
    Avatar
    Mark Waite

    Users of the most recent version of Windows 10 can also set a registry key that will enable long paths across the entire system (rather than just configuring core.longpaths for git).

    There is also a system-wide configuration which can be set for git by a user running as administrator.  Use the "--system" argument instead of "--global".

    Edited by Mark Waite
Please sign in to leave a comment.