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',如此处建议的那样,对于Windows,git的文件名太长,以及https://sifaserdarozen.wordpress.com/2015/06/25/git-file-name-错误时间过长/,但没有帮助。
我还能做些什么吗?
Saikat 的这个回答帮助我解决了 Jenkins git checkout 的这个问题。
遵循的步骤(Windows):
- 以管理员身份运行Git Bash
- 运行以下命令:
git config --system core.longpaths true注意:如果步骤 2 不起作用或出现任何错误,您还可以尝试运行以下命令:
git config --global core.longpaths true阅读更多有关
git config此处的信息。
(编辑:请注意,有一个相关的答案建议将该设置专门应用于受影响的项目,而不是使用--system或--global标志。)
如果您运行 Windows 10 家庭版,您可以更改注册表以启用长路径。
转到HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystemin regedit,然后设置LongPathsEnabled为1。
如果您使用的是 Windows 10 专业版或企业版,您还可以使用本地组策略。
进入Computer Configuration > Administrative Templates > System > Filesystem,gpedit.msc打开Enable Win32 long paths并将其设置为Enabled。
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)
作为解决方法,我在 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)
| 归档时间: |
|
| 查看次数: |
5344 次 |
| 最近记录: |