我很难configurationJenkins,作为Windows服务运行,连接到git服务器(gitosis)并克隆存储库。 jenkins被设置为使用标准的Git插件 。
一切都由我们托pipe:Jenkins服务器在win.foo.com ,gitosis在linux服务器( git.foo.com )上运行。
如果我将RDP放入win.foo.com我可以win.foo.com克隆( git.exe clone --progress -o origin [email protected]:myproject.git myproject ),而不会出现问题。
Jenkins作为服务运行,并且因为它没有在同一用户帐户下运行,所以我已将.ssh文件夹复制到%SystemRoot%\System32\config\systemprofile (在%USERPROFILE%环境variables中定义)和C:\Program Files (x86)\Git\ ,但这些似乎都没有拿起由jenkins,即使完全重新启动。
我试过使用git.exe和git.cmd ; 两种情况都没有喜乐。
Jenkins失败,并显示以下错误消息:
ERROR: Error cloning remote repo 'origin' : Could not clone [email protected]:myproject.git ERROR: Cause: Error performing command: C:\Program Files (x86)\Git\cmd\git.cmd clone --progress -o origin [email protected]:myproject.git C:\Program Files (x86)\Jenkins\jobs\myproject\workspace Command "C:\Program Files (x86)\Git\cmd\git.cmd clone --progress -o origin [email protected]:myproject.git C:\Program Files (x86)\Jenkins\jobs\myproject\workspace" returned status code 128: Cloning into C:\Program Files (x86)\Jenkins\jobs\myproject\workspace... Access denied fatal: The remote end hung up unexpectedly
我确定我错过了一些东西,但我不确定是什么。
build议吗?
我一直在阅读以下与此密切相关的文章: 如何告诉Git for Windows在哪里可以find我的私有RSA密钥? 它提供了一个很好的提示:家庭variables是至关重要的,但它没有按照我的想法。
经过大量的研究和尝试,我发现这篇文章: http : //markashleybell.com/portable-git-windows-setting-home-environment-variable.html
事实上,像往常一样在windows中设置环境variables是不够的,从服务帐户运行ssh,但更改configuration,以便实际上find键。
简短的相关提纲:
导航到C:\ Program Files \ Git \ etc \ profile并添加以下行
HOME="/c/Users/YourUserAccount"
之前
# normalize HOME to unix path HOME="$(cd "$HOME" ; pwd)"
这为我解决了,因为现在Git 总是使用静态分配的path回家。 只要确保这台机器上的其他用户不会遇到任何安全问题。
当Jenkins试图克隆时,您唯一需要检查的参数是%HOME%环境variables值。
您需要显示Jenkins会话的“set”(环境variables),并查看HOME是否已被定义,以及是否已经定义到了哪个path。
提醒:
HOME HOME到%USERPROFILE% 要显示variables,请使用参数化版本function :
在构build器中按名称引用参数。 我使用“
env”命令来显示variables,后面跟着一个echo语句来演示引用该值:
