簡體   English   中英

Jenkins Windows Slave 忽略本地 Git 設置

[英]Jenkins Windows Slave ignoring local Git settings

我已經為 Unix Jenkins master 設置了一個 Windows Jenkins slave。 我正在使用 msysgit 1.9.5 和 Jenkins 1.616 運行 Windows 8.1。

當檢出路徑/文件名超過 255 個字符的存儲庫時,我收到“文件名太長”錯誤。 這是通過在 git 設置core.longpaths設置為 true 來解決的。 然而,Windows Jenkins slave 忽略自定義設置並使用標准設置。

我試過的

  • 在全局、系統、本地設置中在 Windows Jenkins slave 上設置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 slave 仍在使用默認設置運行 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

什么有效

沒有Jenkins 的情況下,在 Windows 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 slave 會忽略自定義設置?

您可以直接配置它,而不是更改運行 Jenkins slave 的用戶。

  • 在適當的“管理員”視圖下設置一個名為 JenkinsSlaveScripts 之類的 Jenkins 多配置項目
  • 我使用基於矩陣的安全性來確保我的常規 Jenkins 用戶不會運行它
  • 將軸配置為在所有 Windows 從站上運行
  • 添加“執行 Windows 批處理腳本”任務

將腳本添加為(類似)

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

當它運行時,它應該更新從站的配置,無論他們以誰的身份運行

Jenkins slave 應該作為用戶jw運行。 這將使 git 獲取您為此用戶輸入的所有設置。
如果作為服務運行,請將服務更新為以用戶jw而非系統用戶身份運行。

我希望這有幫助。

在我的情況下工作的解決方案:

  1. 轉到git安裝文件夾,

  2. 然后編輯 Git\\etc\\gitconfig

  3. 確保它包含

    [核心] 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 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM