我已经为Unix Jenkins主机设置了Windows Jenkins从属设备。我使用msysgit 1.9.5和Jenkins 1.616运行Windows 8.1。
当签出路径/文件名长度超过255个字符的存储库时,我得到"文件名太长"错误。通过在git设置中将core.longpaths
设置为true,这是solved。但是,Windows Jenkins从属设备忽略了自定义设置并使用标准设置。
我尝试了什么
在全局,系统,本地设置中设置Windows Jenkins从属设备上的core.longpaths
:
git config --global core.longpaths true
git config --system core.longpaths true
git config --local core.longpaths true
在Unix Jenkins Master上设置core.longpaths
结果
Windows Jenkins从站仍在使用默认设置运行git。我用
做了一个简单的构建任务"C:\Program Files (x86)\Git\bin\git.exe" config -l
产生
Started by user mles
[EnvInject] - Loading node environment variables.
Building remotely on jw10 in workspace D:\workspace\windowstesting
[windowstesting] $ sh -xe C:\WINDOWS\TEMP\hudson2817786906482449008.sh
+ 'C:\Program Files (x86)\Git\bin\git.exe' config -l
core.symlinks=false
core.autocrlf=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
pack.packsizelimit=2g
help.format=html
http.sslcainfo=/bin/curl-ca-bundle.crt
sendemail.smtpserver=/bin/msmtp.exe
diff.astextplain.textconv=astextplain
rebase.autosquash=true
Finished: SUCCESS
请注意没有core.longpaths=true
。在Windows上Jenkins slave core.longpaths=true
已设置
C:\Users\jw>git config -l
core.symlinks=false
core.autocrlf=true
core.longpaths=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
pack.packsizelimit=2g
help.format=html
http.sslcainfo=/bin/curl-ca-bundle.crt
sendemail.smtpserver=/bin/msmtp.exe
diff.astextplain.textconv=astextplain
rebase.autosquash=true
什么有用
在Windows Jenkins从属上使用非常长的路径/文件名本地克隆存储库,而不使用 Jenkins。
什么行不通
使用 Jenkins 在Windows Jenkins slave 上使用非常长的路径/文件名克隆相同的存储库
Started by user mles
[EnvInject] - Loading node environment variables.
Building remotely on jw10 in workspace D:\workspace\windowstesting
Cloning the remote Git repository
Cloning repository https://github.com/axelhodler/longfile.git
> git init D:\workspace\windowstesting # timeout=10
Fetching upstream changes from https://github.com/axelhodler/longfile.git
> git --version # timeout=10
> git -c core.askpass=true fetch --tags --progress https://github.com/axelhodler/longfile.git +refs/heads/*:refs/remotes/origin/*
> git config remote.origin.url https://github.com/axelhodler/longfile.git # timeout=10
> git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
> git config remote.origin.url https://github.com/axelhodler/longfile.git # timeout=10
Fetching upstream changes from https://github.com/axelhodler/longfile.git
> git -c core.askpass=true fetch --tags --progress https://github.com/axelhodler/longfile.git +refs/heads/*:refs/remotes/origin/*
> git rev-parse "refs/remotes/origin/master^{commit}" # timeout=10
> git rev-parse "refs/remotes/origin/origin/master^{commit}" # timeout=10
Checking out Revision 31b408748324aa6f361828e45ae1d374c3f0fc25 (refs/remotes/origin/master)
> git config core.sparsecheckout # timeout=10
> git checkout -f 31b408748324aa6f361828e45ae1d374c3f0fc25
FATAL: Could not checkout null with start point 31b408748324aa6f361828e45ae1d374c3f0fc25
hudson.plugins.git.GitException: Could not checkout null with start point 31b408748324aa6f361828e45ae1d374c3f0fc25
...
Caused by: hudson.plugins.git.GitException: Command "git checkout -f 31b408748324aa6f361828e45ae1d374c3f0fc25" returned status code 128:
stdout:
stderr: fatal: cannot create directory at 'launchpad/projects/configurationAdminManager/gofer-configurationAdminManager-notification/src/com/mwaysolutions/gofer2/configurationAdminManager/notification/dummydummy/dummydummy/dummydummy/dummydummy/dummydummy/dummydummy': Filename too long
....
Finished: FAILURE
我无法在开头添加另一个构建步骤来设置core.longpaths
,因为在运行任何构建步骤之前,检查存储库是jenkins所做的第一件事。
我的Windows Jenkins奴隶会忽略自定义设置的任何想法吗?
答案 0 :(得分:2)
Jenkins slave应该以用户jw
身份运行。这将使git获取您为此用户输入的所有设置
如果作为服务运行,请将服务更新为用户jw
,而不是系统用户。
我希望这会有所帮助。
答案 1 :(得分:2)
您可以直接对其进行配置,而不是更改Jenkins从站运行的用户。
添加脚本(类似于)
cd c:\dev-software\git-2.7.1\bin
git config --global core.longpaths true
git config --system core.longpaths true
git config --local core.longpaths true
echo %USERPROFILE%\.gitconfig on %COMPUTERNAME%
type %USERPROFILE%\.gitconfig
当它运行时,它应该更新奴隶的配置,无论他们是谁正在运行
答案 2 :(得分:0)
在我的情况下有效的解决方案:
转到git安装文件夹,
然后编辑Git \ etc \ gitconfig
确保其中包含
[核心] longpaths = true
示例:
[http]
sslBackend = schannel
[diff "astextplain"]
textconv = astextplain
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true
[core]
autocrlf = false
fscache = true
symlinks = false
longpaths = true
[pull]
rebase = true