E-mail commit webhook for Gitlab

E-mail commit webhook for Gitlab

Michele Alexander Wittmann 21. July 2014 Releases

0 Comments // Reading Time: 3 min.

Some time ago we already talked about the Open-Source Code Management Tool Gitlab in our blog. In two articles we talked about what Gitlab is, which functions can be covered with this tool and how you can extend Gitlab with the help of Webhooks.

Especially the extension possibilities of Gitlab via Webhooks make this system very interesting, because every tool lacks functions that you don't want to miss in your working environment. For example, we have extended our Gitlab with a Commit-Webhook, since such a feature did not exist at that time yet. Meanwhile there is a simplified version in the Gitlab itself.

With the help of this webhook, all team members of a project are notified via e-mail about a push into the Git repository. So you don't have to log into Gitlab on the way to keep a rough overview. The commit diffs are added to the e-mails. In the webhook itself, you can configure whether the diffs should be displayed as a data attachment or as HTML.

We at sgalinski Internet Services live and love open source. In this sense we don't want to withhold the code of the Webhook from you. We would be happy if you would give us your feedback.

The installation of the webhook is a breeze thanks to Composer. Composer is currently on everyone's lips and simplifies the life of the developers immensely. If you have already installed Composer you can skip the first two commands.

curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer

These two commands install Composer on your computer. These commands only work on a UNIX-based operating system. If you are using a Windows server, you need to install Composer according to these instructions.

Now we come to the actual installation of the webhook. The webhook should be installed on a webserver, otherwise Gitlab cannot call the hook via HTTP.

git clone http://gitlab.sgalinski.de/gitlab/commit-webhook webhook
cd webhook
composer install

After these three lines, the webhook is complete from the code base and still needs to be configured.

A text file is used for configuration, which is noted in YAML format. For simplicity, we have a sample configuration in the git repository.

mv config.yaml.example config.yaml
vim config.yaml

In the file config.yaml you have to configure the sections Gitlab and Mail. For your Gitlab the domain has to be adapted and an authentication token has to be set. This would make the webhook itself ready for use. But since you also want to have e-mails with correct senders, the e-mail addresses should still be adapted in the mail configuration.

Once the configuration is saved, there is only one thing left to do. The webhook has to be entered in the Gitlab of the desired project and every time you push it, it says "You have mail".

We would be pleased about feedback to the Webhook. You can do this via Twitter or Google+. Furthermore you can create bug reports and feature requests in our Gitlab. You can also find the source code of the hook here.


No comments.
    Drop files here