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?
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
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
.
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'
This answer by Saikat worked for me to fix this issue for a Jenkins git checkout.
Steps to follow (Windows):
- Run Git Bash as administrator
- 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.)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.