Skip to content

Instantly share code, notes, and snippets.

Gerrit notifications via Rocket.Chat

Case

Gerrit often sends a lot of emails, especially if you take part in many projects. For a while we felt that sometimes it's hard to notice the most important ones, like reviewers' and Sputnik's comments on our changes. We use Rocket.Chat for text communication inside the company and most of us are connected throughout the day, so we thought it might be useful to get chat message notification every time a comment is added on one's changes.

Gerrit hooks

Gerrit has a built-in mechanism for running hooks - scripts that are called whenever a specific event occurs. The script must be named the same as the hook. We created a bash script named comment-added, which is run every time someone adds a comment. Gerrit provides it with a lot of useful parameters, like project name, comment author, score, change owner, etc. Full documentation can be found here. After parsing

@royalth
royalth / comment-added
Last active August 24, 2017 10:26
Gerrit comment-added hook sending Rocket.Chat messages to change owner
#!/bin/bash
logFile=/tmp/comment-added.log
CHANGEURL=
PROJECT=
AUTHOR=
COMMENT=
SCORE=
OWNER=