Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Filename too long" error in Jenkins git checkout

Tags:

git

jenkins

Git checkout in Jenkins throws the error "Filename too long" and fails, as follows:

hudson.plugins.git.GitException: Command "git.exe checkout -f 2cea7d8eb9185899c01d2ffc86872f584da2e60c" returned status code 1:

stdout:
stderr: error: unable to create file some_long_named_project/src/test/resources/dbunit_test_data/com/some_long_named_directory/data/testInstances_create_dataRequiresData.xml: Filename too long

I've set the longpaths variable in the config file to 'true', as suggested here Filename too long in Git for Windows and here https://sifaserdarozen.wordpress.com/2015/06/25/git-file-name-too-long-error/, but it didn't help.

Is there anything else I can do?

like image 350
JoshuaF Avatar asked Jul 20 '17 18:07

JoshuaF


Video Answer


4 Answers

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
like image 91
user2957741 Avatar answered Sep 26 '22 03:09

user2957741


This answer by Saikat worked for me to fix this issue for a Jenkins git checkout.

Steps to follow (Windows):

  1. Run Git Bash as administrator
  2. Run the following command:

git config --system core.longpaths true

Note: if step 2 does not work or gives any error, you can also try running this command:

git config --global core.longpaths true

Read more about git config here.

(EDIT: Note that there's a related answer which suggests to apply the setting specifically to the affected project rather than using the --system or --global flags.)

like image 36
sonny Avatar answered Sep 24 '22 03:09

sonny


If you run Windows 10 Home Edition you could change you Registry to enable Long Paths.

Go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem in regedit and then set LongPathsEnabled to 1.

If you have Windows 10 Pro or Enterprise you could also use Local Group Policies.

Go to Computer Configuration > Administrative Templates > System > Filesystem in gpedit.msc, open Enable Win32 long paths and set it to Enabled.

like image 21
Julian Veerkamp Avatar answered Sep 24 '22 03:09

Julian Veerkamp


As a workaround I defined a virtual drive for WORKSPACE path in jenkinsfile script:

bat 'subst W: /d || exit 0' //delete the virtual drive if it already exists 
bat 'subst W: "%WORKSPACE%"' 

and later delete it:

bat 'subst W: /d'
like image 41
Nima Marashi Avatar answered Sep 23 '22 03:09

Nima Marashi