簡體   English   中英

將Git與Jenkins搭配使用私人git回購

[英]Using Git with Jenkins with a private git repo

我很難讓Git與Jenkins合作。 我已經在Windows 2008服務器計算機上使用gitblit設置了一個私人git repo。 我已經在gitblit中創建了一個供jenkins使用的帳戶(即:用戶名:jenkins,密碼:password,公司:test)。 我已經創建了證書,並允許使用ssh和https進行訪問。

使用命令提示符,我可以通過在命令行中鍵入以下命令來使克隆工作:

git clone ssh://jenkins@repo.test.com:29418/testrepo/WebApp.git c:\test

上面的命令在檢索代碼之前要求我輸入密碼。 由於我試圖用詹金斯編寫腳本,因此我嘗試:

git clone ssh://jenkins:password@valrepo.test.com:29418/testrepo/WebApp.git c:\test

但我收到以下錯誤:

ssh: Could not resolve hostname jenkins: no address associated with name
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.

好吧,讓我嘗試https命令。 因此,我嘗試以下操作:

git https://jenkins@valrepo.test.com/r/testrepo/WebApp.git C:\test

但出現以下錯誤:

fatal: unable to access 'https://jenkins@valrepo.test.com/r/testrepo/WebApp.git/': SSL certificate problem: self signed certificate in certificate chain

所以我想為什么不嘗試sslVerify = false命令。 我在命令提示符下嘗試以下操作:

git -c http.sslVerify=false clone https://jenkins@valrepo.test.com/r/testrepo/WebApp.git C:\test

它在命令提示符下工作。 但是,當我在Jenkins中將其作為腳本命令嘗試使用時,Jenkins最終會掛起而沒有下載任何內容。 不知道為什么。

我嘗試過的其他方法是使用內置的Git插件,但是我也無法正常工作。

我沒有關於如何使它在詹金斯上工作的想法。 有人有經驗嗎?

我可以通過使用PSEXEC(Jenkins在系統帳戶下運行)作為SYSTEM帳戶登錄並使用以下命令將證書添加到git repo來修復該問題:

git config --global http.sslCert path/to/jenkins.pem
openssl rsa -in path/to/jenkins.pem -out path/to/jenkins.key    
git config --global http.sslKey path/to/jenkins.key

暫無
暫無

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

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