我刚开始使用 TeamCity 。我正在尝试弄清楚如何从我的私有(private) GitHub 存储库构建代码。为了尝试做到这一点,我执行了以下操作。
创建部署 key
- 使用 PuttyGen 创建了新的 SSH key 。
- 为 key 提供密码。
- 将私钥另存为“private.ppk”。
- 将公钥另存为“public.pub”。
- 使用“转换”->“导出 OpenSSH key ”将 OpenSSH 格式的 key 导出为“key.ssh”。
将部署 key 添加到 GitHub
- 何时项目存储库(即 https://github.com//)
- 点击“设置”
- 点击“部署 key ”
- 点击“添加部署 key ”
- 在“添加部署 key ”中,输入“TeamCity”作为标题,然后将 PuTTYGen 中的公钥复制并粘贴到“ key ”字段中。
在 TeamCity 中创建了我的项目
- VCS 类型:Git
- VCS 根名称:“项目主控”
- VCS 根 ID:“Project_Master”
- 获取 URL:“git://github.com//.git
- 默认分支:“refs/heads/master”
- 身份验证方法:“上传 key ”
- 用户名:“git”
- 上传的 key :“key.ssh”(之前上传)
- 密码:
当我单击“测试连接”时,收到错误消息。错误是:
Test connection failed in <ProjectName> :: <BuildName>
Incorrect url git://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5c3b35281c3b352834293e723f3331" rel="noreferrer noopener nofollow">[email protected]</a>/<username>/<repo-name>.git: anonymous git url should not contain a username
如果我删除“用户名”字段,我会收到相同的错误。如果我将 Fetch URL 更改为 GitHub (https://github.com//.git) 中列出的 url,则会收到一条错误消息:
Test connection failed in <ProjectName> :: <BuildName>
List remote refs failed: org.eclipse.jgit.errors.TransportException: https://github.com/<username>/<repo-name>.git: not authorized
我做错了什么?
最佳答案
您需要确保将公钥上传到 GitHub,然后在 TeamCity 实例中使用私钥。此外,SSH key 仅在使用 ssh:
协议(protocol)访问 GitHub 时使用,而非 https:
协议(protocol)。
关于git - 通过 GitHub 上的 TeamCity 进行部署,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31300827/