Jenkins ⇔ Github-多个存储库的 Webhook 设置
Jenkins ⇔ Github-Webhook setup for multiple repositories
为了让 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 配置的远程 url,我得到了一些东西 运行。所以 SCM 会匹配 webhook,而 jenkins 当 运行 git push
会使用 .ssh/config
信息。
问题
我还可以做些什么 ?有没有更好、更容易实现自动化的方法?
我停止使用 deploy key
并在 jenkins 上添加了我自己的帐户凭据,以便能够处理所有存储库而无需使用 .ssh/config
更改主机。
为了让 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 配置的远程 url,我得到了一些东西 运行。所以 SCM 会匹配 webhook,而 jenkins 当 运行 git push
会使用 .ssh/config
信息。
问题
我还可以做些什么 ?有没有更好、更容易实现自动化的方法?
我停止使用 deploy key
并在 jenkins 上添加了我自己的帐户凭据,以便能够处理所有存储库而无需使用 .ssh/config
更改主机。