【发布时间】:2016-04-17 20:45:44
【问题描述】:
为了让 Jenkins 能够访问同一服务器上的多个存储库,我将.ssh/config 设置如下:
Host a.github.com
HostName github.com
User git
IdentityFile ~/.ssh/project-a-id_rsa
# same for other repos
并将 Jenkins 作业的 源代码管理 (SCM) 设置为 git 和 git@a.github.com:user/repo_a.git。它工作正常。
问题
我希望在推送事件上触发这些作业,所以我在 github 中设置了一个 webhook 服务,即 Jenkins(GitHub 插件)。从 webhook 收到的请求是“POST for https://github.com/user/repo_a”,它与 SCM 中设置的主机不同,即a.github.com。
因为它们不同,所以作业不会自动构建。
丑陋的解决方案
我通过将 SCM 设置为 github.com 并在使用 a.github.com 克隆后覆盖项目 git config 的远程 url 来运行一些东西。因此 SCM 将匹配 webhook,并且 jenkins 在运行 git push 时将使用 .ssh/config 信息。
问题
我还可以做些什么 ?有没有更好、更容易自动化的方法来实现这一目标?
【问题讨论】:
-
我也有同样的问题。我在 github webhooks 页面上遇到超时错误,我认为这是因为我使用的是私有存储库(所以 ssh 密钥)
标签: github jenkins jenkins-plugins github-enterprise