从 TeamCity 代理推送到 github

Pushing to github from a TeamCity agent

我使用 TeamCity 构建代理来构建代码。当我构建它时,我更改了一个文件,提交它并想将其推回。我不想在构建步骤的命令行中使用我的密码。因此,我使用 SSH Exec 运行器类型。我制作了一把钥匙,将 public 一把上传到 github,将私人一把上传到 TeamCity。我创建构建步骤: 认证方式:上传密钥 目标:github.com 用户名:git Select 键:id_rsa 命令:git 获取原始主机

我得到这样的错误:

Permanently added 'github.com' (RSA) to the list of known hosts.
  Executing commands:
eval “$(ssh-agent -s)”
on host [github.com]
  Invalid command: 'git fetch origin master'
    You appear to be using ssh to clone a git:// URL.
    Make sure your core.gitProxy config option and the
    GIT_PROXY_COMMAND environment variable are NOT set.
  SSH exit-code 1
  Step checkout watchtower (SSH Exec) failed

我尝试了不同的命令,例如'eval “$(ssh-agent -s)”',结果是一样的。 那么,如何从 TeamCity 代理获取或推送到 github?

如果如评论所述,您正在使用 git:// URL,但无法轻松更改它,您仍然可以在 TeamCity 代理上添加:

git config --global url.git@github.com:.insteadOf git://github.com/

无需修改您的 URL,TeamCity 将使用 SSH URL 而不是 git://

问题出在代理上的 ssh 身份验证错误中。当我将 rsa 密钥复制到 /root/.ssh 时,我可以在 "Command line" 构建步骤中执行: git clone -b test ssh://git@github.com/repo_name.git 测试 根帐户由代理使用。我不知道为什么 TeamCity 不使用我在构建设置中提供的密钥。