You need to enable JavaScript to run this app.
导航

Gerrit 配置 Webhook 推送

最近更新时间2022.04.24 11:34:38

首次发布时间2022.04.24 11:34:38

对于 Gerrit 代码仓库,开启 Webhook 触发后,您需前往对应代码仓库配置流水线的 Webhook 地址。

背景信息

Gerrit 代码仓库一般为私有化部署,仓库界面没有 Webhook 配置入口,用户需在本地编写完成 webhooks.config 文件,并将该配置文件推送至对应 project 下的 refs/meta/config 分支。

前提条件

已勾选目标流水线的 Webhook 设置,并且将对应的 Webhook URL 复制出来。具体操作请参见 代码源触发

操作步骤

  1. 拉取 Gerrit 代码仓库远端分支。
git fetch origin refs/meta/config:refs/remotes/origin/meta/config
  1. 切换到 meta/config 分支。
git checkout meta/config
  1. 编写 webhooks.config 文件。
    vim webhooks.config
    [remote "changemerged"] 
    url = ${webhook\_url} # 填入准备好的流水线 Webhook URL
    event = change-merged # 推送事件的名称
    maxTries = 2 
    sslVerify = false 
    
  2. 将该配置文件推送至目标 project 下的 refs/meta/config 分支。
git add . && git commit -m "add webhook config" && git push origin meta/config:meta/config