Karthik
Karthik

Reputation: 13

Gerrit ref-update hook is not getting invoked

Installed Gerrit (version 2.13.1) by following the steps in the following link:
https://gerrit-review.googlesource.com/Documentation/install-quick.html in Ubuntu 16.04 environment.

Created a hooks folder in '$site_path'/hooks and added a ref-update hook file which just exits with return code 1.

Provided executable permissions to this file.

After Gerrit server restart, it is allowing me to do a push operation.

Upvotes: 1

Views: 2064

Answers (3)

Christine
Christine

Reputation: 21

I'm using Gerrit 2.14. This works for me:

Behavior change in ref-update hook

Instead of being invoked on every commit received, the ref-update hook is now invoked before the ref update operation is finalized. The previous behavior of the ref-update hook is moved into a new hook named commit-received.

Sites using the ref-update hook should rename the hook file to commit-received.

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

Upvotes: 2

Mateusz Wocka
Mateusz Wocka

Reputation: 31

You can also add hooks manually:

  1. Create folder for example /hooks
  2. Add in this folder file ref-update
  3. Make this file executable using this command chmod +x ref-update
  4. Last things is add text below to gerrit.config file, my file is in /var/gerrit/review_site/etc/ but please check where yours file is

This you need add to your gerrit.config file:

[hooks]
     path = /hooks

In generally way:

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

Upvotes: 0

Since Gerrit 2.13 you have to install the hooks plugin.

See more details at Gerrit 2.13 Release Notes and Gerrit Documentation.

The hooks plugin is a core plugin, it is packaged within the Gerrit war file and can be installed executing:

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

More info here.

Upvotes: 2

Related Questions