How to setup git-mulitmail on gitolite

From Wiki
Jump to navigation Jump to search


git-multimail is a tool for sending notification emails on pushes to a Git repository. It can be used as a hook script directly or can be imported as a Python module into another script.

If one uses gitolite, there are several ways to install and use multimail.

This short how-to describes a setup where multimail can be activated on a per-repository basis. This setup also allows the chaining of multiple post-receive hooks.

Changes to .gitolite.rc

To make this work a few changes have to be made to the gitolite configuration file .gitolite.rc. Thus login to your server with the user gitolite was installed with and make the changes described below. The config file should be in the user's home directory.

GIT_CONFIG_KEYS is used to allow the repo admin to define acceptable gitconfig keys. To allow all configuration keys that start with multimailhook., set the variable to multimailhook\..*. If you want to allow all keys, set it to .*.

GIT_CONFIG_KEYS           =>  '.*',

The next variable LOCAL_CODE can have far reaching consequences on how one administers gitolite. If you want to learn about the details, have a look at the gitolite documentation on this topic.

I like to use the gitolite-admin repository to manage hooks, therefore I set this variable to $rc{GL_ADMIN_BASE}/local.

LOCAL_CODE                =>  "$rc{GL_ADMIN_BASE}/local",

The last step allows the use of repository sepecific hooks in gitolite.


Installing the post-receive hook

Go to your gitolite-admin repository and create a directory local/hooks/repo-specific.

Now copy into that directory, rename it to multimail, and don't forget to set the executable bit (chmod 755 multimail). Oh, btw, adding, committing, and pushing helps too. 😏

Note: You can rename to whatever you want, but you will have to use that name later, thus the simpler (and more descriptive), the better.

Activating multimail for a repository

To activate multimail for the repository my-repo-with-multimail add the last 3 lines to your gitolite repo configuration.

repo my-repo-with-multimail
    RW+                              =   user_with_rw_access
    option         =   multimail
    config multimailhook.from        =   # From address to use, e.g.
    config multimailhook.mailinglist =   # Where emails should be sent, e.g.

If you want to chain multiple hooks, a detailed description is available in the gitolite documentation. See the last few paragraphs in the section repo-specific-hooks.

Deactivating multimail for a repository

To deactivate multimail, you have to explicitly set the according parameters to an empty string, although it would suffice to just delete the hook itself.

repo my-repo-with-multimail
    RW+                              =   user_with_rw_access
    option         =   ""
    config multimailhook.from        =   "" # you could also leave this line as it was
    config multimailhook.mailinglist =   "" # you could also leave this line as it was