GitException File Name Too Long

Article ID:225851008
1 minute readKnowledge base

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

This article is part of our Knowledge Base and is provided for guidance-based purposes only. The solutions or workarounds described here are not officially supported by CloudBees and may not be applicable in all environments. Use at your own discretion, and test changes in a safe environment before applying them to production systems.