【问题标题】:Jenkins ⇔ Github-Webhook setup for multiple repositoriesJenkins ⇔ Github-Webhook 为多个存储库设置
【发布时间】: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) 设置为 gitgit@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


【解决方案1】:

我停止使用 deploy key 并在 jenkins 上添加了我自己的帐户凭据,以便能够处理所有存储库,而无需使用 .ssh/config 更改主机。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-02-26
    • 1970-01-01
    • 1970-01-01
    • 2018-08-02
    • 2011-04-04
    • 2011-08-16
    • 1970-01-01
    相关资源
    最近更新 更多