Jenkins git checkout中的“文件名太长”错误

Jos*_*uaF 5 git jenkins

Jenkins中的Git Checkout抛出错误“文件名太长”并失败,如下所示:

hudson.plugins.git.GitException:命令“ git.exe签出-f 2cea7d8eb9185899c01d2ffc86872f584da2e60c”返回了状态代码1:

stdout:
stderr:错误:无法创建文件edgemagic-nextgen-core / src / test / resources / dbunit_test_data / com / cybra / edgemagic / service / EmObjectServiceTest / data / testInstances_create_dataRequiresData.xml:文件名太长

我已将配置文件中的longpaths变量设置为'true',如此处建议的那样,对于Windowsgit的文件名太长,以及https://sifaserdarozen.wordpress.com/2015/06/25/git-file-name-错误时间过长/,但没有帮助。

我还能做些什么吗?

son*_*nny 6

Saikat 的这个回答帮助我解决了 Jenkins git checkout 的这个问题。

遵循的步骤(Windows):

  1. 管理员身份运行Git Bash
  2. 运行以下命令:

git config --system core.longpaths true

注意:如果步骤 2 不起作用或出现任何错误,您还可以尝试运行以下命令:

git config --global core.longpaths true

阅读更多有关git config 此处的信息。

(编辑:请注意,有一个相关的答案建议将该设置专门应用于受影响的项目,而不是使用--system--global标志。)


Jul*_*amp 5

如果您运行 Windows 10 家庭版,您可以更改注册表以启用长路径。

转到HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystemin regedit,然后设置LongPathsEnabled1

如果您使用的是 Windows 10 专业版或企业版,您还可以使用本地组策略。

进入Computer Configuration > Administrative Templates > System > Filesystemgpedit.msc打开Enable Win32 long paths并将其设置为Enabled


use*_*741 5

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
Run Code Online (Sandbox Code Playgroud)


Nim*_*shi 2

作为解决方法,我在 jenkinsfile 脚本中为 WORKSPACE 路径定义了一个虚拟驱动器:

bat 'subst W: /d || exit 0' //delete the virtual drive if it already exists 
bat 'subst W: "%WORKSPACE%"' 
Run Code Online (Sandbox Code Playgroud)

然后删除它:

bat 'subst W: /d'
Run Code Online (Sandbox Code Playgroud)