Gerrit ref-update 挂钩未被调用

Gerrit ref-update hook is not getting invoked

已按照以下步骤安装 Gerrit(版本 2.13.1)link:
https://gerrit-review.googlesource.com/Documentation/install-quick.html 在 Ubuntu 16.04 环境中。

在“$site_path”/hooks 中创建了一个 hooks 文件夹并添加了一个 ref-update 挂钩文件,该文件以 return 代码 1 退出。

已提供此文件的可执行权限。

Gerrit 服务器重启后,允许我进行推送操作。

从 Gerrit 2.13 开始,您必须安装 hooks 插件。

Gerrit 2.13 Release Notes and Gerrit Documentation 查看更多详细信息。

hooks 插件是一个核心插件,它被打包在 Gerrit war 文件中,可以执行安装:

java -jar gerrit.war init -d <site_path> --install-plugin=hooks

更多信息here

您也可以手动添加挂钩:

  1. 创建文件夹,例如 /hooks
  2. 在此文件夹中添加文件 ref-update
  3. 使用此命令使此文件可执行chmod +x ref-update
  4. 最后一件事是将下面的文本添加到 gerrit.config 文件,我的文件在 /var/gerrit/review_site/etc/ 但请检查你的文件在哪里

您需要将此添加到您的 gerrit.config 文件中:

[hooks]
     path = /hooks

一般情况下:

[hooks]
     path = /path/to/yours/hooks/folder/hooks

我正在使用 Gerrit 2.14。这对我有用:

引用更新挂钩中的行为更改

ref-update 挂钩现在在 ref 更新操作完成之前被调用,而不是在每次收到提交时都被调用。 ref-update 挂钩的先前行为已移至名为 commit-received 的新挂钩中。

使用 ref-update 挂钩的站点应将挂钩文件重命名为 commit-received。

https://www.gerritcodereview.com/releases/2.14.md#Behavior-change-in-ref_update-hook