TeamCity-来自代理的Git推送
我已经设置了一个TeamCity服务器,在代理上使用“默认私钥”和.ssh中的配置文件从GitHub签出src,如下所示:TeamCity-来自代理的Git推送,git,push,teamcity,agent,Git,Push,Teamcity,Agent,我已经设置了一个TeamCity服务器,在代理上使用“默认私钥”和.ssh中的配置文件从GitHub签出src,如下所示: Host git@github.com IdentityFile ~/.ssh/id_rsa.shop StrictHostKeyChecking no Host github.com IdentityFile ~/.ssh/id_rsa.shop StrictHostKeyChecking no 这个很好用。 现在我想从探员那里推。 但
Host git@github.com
IdentityFile ~/.ssh/id_rsa.shop
StrictHostKeyChecking no
Host github.com
IdentityFile ~/.ssh/id_rsa.shop
StrictHostKeyChecking no
这个很好用。
现在我想从探员那里推。
但是,执行此操作时,push命令由于用户输入而挂起:
The authenticity of host 'github.com (192.30.252.130' can't be established.
RSA key fingerprints is 'xxx....xxx'
Are you sure you want to continue (yes/no)
Warning: Permently added '' to known hosts.
Connection closed by 192.30.252.130
Fatal: The remote end hung up unexpectedly.
如果我手动执行此操作,无论我是否键入“是/否”,它仍然会失败,权限被拒绝
“默认私钥”具有github的读/写权限,所以我有点不知所措。
我观察到的唯一一件事是github ip看起来非常本地,但当代理刚刚完成代理端签出时,这怎么可能呢?这可能是防火墙吗
谁能给我解释一下我遗漏了什么吗?事实证明,这个设置有很大的缺陷。 显然,我不太理解调用git后用户上下文/配置文件的变化。 这将改变homedir。 这可以通过查看Git etc文件进行验证,该文件更改了名为:profile:
# Set up USER's home directory
if [ -z "$HOME" -o ! -d "$HOME" ]; then
HOME="$HOMEDRIVE$HOMEPATH"
if [ -z "$HOME" -o ! -d "$HOME" ]; then
HOME="$USERPROFILE"
fi
fi
if [ ! -d "$HOME" ]; then
printf "\n\033[31mERROR: HOME directory '$HOME' doesn't exist!\033[m\n\n"
echo "This is an error which might be related to msysGit issue 108."
echo "You might want to set the environment variable HOME explicitly."
printf "\nFalling back to \033[31m/ ($(cd / && pwd -W))\033[m.\n\n"
HOME=/
fi
# normalize HOME to unix path
HOME="$(cd "$HOME" ; pwd)"
我通过将home dir强制为当前用户修复了此问题,如下所示:
set HOME=%env.USERPROFILE%
问题出在git的init脚本中
此外,我必须修改配置以:
Host webshop_github
HostName github.com
User git
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa.shop
实际上,由于@Christian Mikkelsen和本文中的答案,我已经深入了解了一些,并找到了另一个解决方案: 手动使用git时,不应该使用原始的
git.exe
,而应该使用包装器-gitk.cmd
或cmd\git.exe
。请注意,cmd\git.exe
与bin\git.exe
不同。Teamcity本身使用bin\git.exe
,因为它知道如何使用它。但是如果您手动使用git,您应该使用cmd\git.exe
您必须解决的问题是如何将
cmd\git.exe
的路径传递到脚本中。我支持在执行脚本之前,可以使用自定义参数或重写env.TEAMCITY\u GIT\u路径来完成此操作。这真的很奇怪。我在Windows代理上遇到了同样的问题。我已经用你的解决方案解决了。非常感谢!