2015-01-05 124 views
2

我現在試圖設置一個Jenkins作業(在一臺Windows服務器上)來監視位於Gitosis服務器(位於不同Windows服務器上)的內部Git倉庫。爲什麼Jenkins的Git插件會用額外的斜槓重寫我的本地git倉庫?

url看起來像這樣:ssh://[email protected]:relative_path/repo.git(實際值替換爲安全性,相對路徑也不會與'〜/'一起使用,它只是沒有領先的'/')。

從命令行使用url運行git clone時,一切都很好。

當在Jenkins作業中配置Git SCM時,它能夠運行ls-remote命令(這證實ssh密鑰已針對Jenkins實例正確配置)。

但是,當作業執行時,url似乎被一個額外的正斜槓重寫,導致clone命令失敗。

Started by user Meh 
[EnvInject] - Loading node environment variables. 
Building in workspace D:\local_repo_test 
> git.exe rev-parse --is-inside-work-tree # timeout=10 
Fetching changes from the remote Git repository 
> git.exe config remote.origin.url ssh:///[email protected]:relative_path/repo.git # timeout=10 
Fetching upstream changes from ssh:///[email protected]:relative_path/repo.git 
> git.exe --version # timeout=10 
> git.exe -c core.askpass=true fetch --tags --progress ssh:///[email protected]:relative_path/repo.git +refs/heads/*:refs/remotes/origin/* 
ERROR: Error fetching remote repo 'origin' 
ERROR: Error fetching remote repo 'origin' 
Finished: FAILURE 

這是困擾我的'///'。有沒有人看過類似的東西?

任何幫助,將不勝感激。

回答

1

由於我無法與詹金斯人一起試圖解決爲什麼url被'///'重寫並且我也無法確定Gitosis是否有任何問題,我想出了一個解決方法。

由於Cygwin,SSH和Gitosis已經安裝並正在運行,我決定向該機器添加一個新用戶並通過它運行所有git ssh命令。

遵循的步驟此處添加新的用戶http://techtorials.me/cygwin/create-and-add-users/

然後我chmod'ed和chgrp'ed /家/的git/reposotories到sshUsers組。一旦到位,我就可以使用絕對路徑名的Git SSH網址繞過jenkins的'///'url問題。

+0

我在最新的Jenkins版本中遇到同樣的錯誤,當它試圖從Gerrit內部repo配置克隆時 – daniilyar

+0

我通過更新Jenkins作業來使用「HEAD:refs/heads/master」作爲refspec – daniilyar

2

據我所知,通過檢查各種版本的git可以看出,你使用ssh協議的相對路徑語法是不明確的。它被解釋爲你希望在Windows上的msysgit版本,但不是在我測試的任何其他平臺上。

當我測試

  • GIT中1.7.1,CentOS的6.6,git clone ssh://[email protected]:bin/失敗並報告ssh: Could not resolve hostname mark-pc1:bin: Name or service not known
  • GIT中1.7.2.5,Debian的6,git clone ssh://[email protected]:bin/失敗並報告ssh: Could not resolve hostname mark-pc1:bin: Name or service not known
  • GIT中1.7.10.4, Debian 7,git clone ssh://[email protected]:bin/失敗並報告ssh: Could not resolve hostname mark-pc1:bin: Name or service not known
  • git 2.1.4,Debian Testing,git clone ssh://[email protected]:bin/失敗並報告fatal: '/' does not appear to be a git repository
  • git 2.2.1,Ubuntu 14.04,git clone ssh://[email protected]:bin/失敗並報告「致命:'/'似乎不是git存儲庫」
  • git 2.3.0,Ubuntu 14。04,git clone ssh://[email protected]:ssh/home/mwaite/bin成功和克隆使用ssh協議

從/家/ mwaite/bin中的回購據我所知,如果冒號後的第一個字是一個協議(如ssh)或端口號(如22),那麼它被解釋爲要用於存儲庫訪問的服務或端口號。

我進一步說明其中的一些細節JENKINS-26680JENKINS-27483

0

這是一個遠射,但只是爲了檢查 - 你也許在路徑中使用的參數?就像$ PROTOCOL/$ URL/$ PATH和PROTOCOL ='ssh://'一樣?聽起來很牽強,所以沒有冒犯的意思。但我曾經做過類似的事情,並且參數化使我無法看到該領域實際上發送的是一個比應該更多的斜線。

0

我在使用Jenkins和我想通過ssh克隆的專用bitbucket存儲庫結合時遇到了同樣的問題。正如Mark Waite的回答中所提到的,這被有些人認爲是一個錯誤。然而,也有其他人認爲這是預期的行爲,因爲'相對URI'沒有被支持JENKINS-26327

,在我的情況下工作

暫時的解決辦法是添加的端口號22,所以在詹金斯管道我換成

url: 'ssh://[email protected]:/my_team/my_repo.git' 

url: 'ssh://[email protected]:22/my_team/my_repo.git' 

而且現在的管道運行正常。

相關問題