繁体   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