我使用 TeamCity 构建代理来构建代码。当我构建它时,我更改了一个文件,提交它并想要将其推回。我不想在构建步骤的命令行中使用我的密码。所以,我使用 SSH Exec 运行器类型。我制作了一个 key ,将公共(public) key 上传到 github,将私有(private) key 上传到 TeamCity。我创建构建步骤:
认证方式:上传 key
目标:github.com
用户名:git
选择键:id_rsa
命令: git fetch origin master
我得到这样的错误:
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?
最佳答案
问题在于代理上的 ssh 身份验证错误。当我将 rsa key 复制到/root/.ssh 时,我可以在“命令行”构建步骤中执行以下操作:
git clone -b test ssh://git@github.com/repo_name.git test
代理使用根帐户。我不知道为什么 TeamCity 不使用我在build设置中提供的 key 。
关于git - 从 TeamCity 代理推送到 github,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62327092/