How to setup git-mulitmail on gitolite: Difference between revisions

From evermeet.cx Wiki
Jump to navigation Jump to search
Created page with "== Introduction == [https://github.com/git-multimail/git-multimail git-multimail] is a tool for sending notification emails on pushes to a [https://git-scm.com/ Git] reposito..."
 
m fix broken links
 
(One intermediate revision by the same user not shown)
Line 9: Line 9:
== Changes to <code>.gitolite.rc</code> ==
== Changes to <code>.gitolite.rc</code> ==


To make this work a few changes have to be made to the [http://gitolite.com/gitolite/rc/ gitolite configuration file] <code>.gitolite.rc</code>. 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.
To make this work a few changes have to be made to the [http://gitolite.com/gitolite/rc gitolite configuration file] <code>.gitolite.rc</code>. 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.


<code>GIT_CONFIG_KEYS</code> is used to allow the repo admin to define acceptable gitconfig keys. To allow all configuration keys that start with <code>multimailhook.</code>, set the variable to <code>multimailhook\..*</code>. If you want to allow all keys, set it to <code>.*</code>.
<code>GIT_CONFIG_KEYS</code> is used to allow the repo admin to define acceptable gitconfig keys. To allow all configuration keys that start with <code>multimailhook.</code>, set the variable to <code>multimailhook\..*</code>. If you want to allow all keys, set it to <code>.*</code>.
Line 17: Line 17:
</pre>
</pre>


The next variable <code>LOCAL_CODE</code> can have far reaching consequences on how one administers gitolite. If you want to learn about the details, have a look at the [http://gitolite.com/gitolite/non-core/#for-non-core-programs-shipped-with-gitolite gitolite documentation on this topic].
The next variable <code>LOCAL_CODE</code> can have far reaching consequences on how one administers gitolite. If you want to learn about the details, have a look at the [http://gitolite.com/gitolite/non-core#for-non-core-programs-shipped-with-gitolite gitolite documentation on this topic].


I like to use the gitolite-admin repository to manage hooks, therefore I set this variable to <code>$rc{GL_ADMIN_BASE}/local</code>.
I like to use the gitolite-admin repository to manage hooks, therefore I set this variable to <code>$rc{GL_ADMIN_BASE}/local</code>.
Line 38: Line 38:
Now copy <code>git_multimail.py</code> into that directory, rename it to <code>multimail</code>, and don't forget to set the executable bit (<code>chmod 755 multimail</code>). Oh, btw, adding, committing, and pushing helps too. &#x1F60F;
Now copy <code>git_multimail.py</code> into that directory, rename it to <code>multimail</code>, and don't forget to set the executable bit (<code>chmod 755 multimail</code>). Oh, btw, adding, committing, and pushing helps too. &#x1F60F;


'''Note:''' You can rename <code>git_multimail.py</code> to whatever you want, but you will have to use that name later, thus the simpler (and descriptive), the better.
'''Note:''' You can rename <code>git_multimail.py</code> 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 ==  
== Activating multimail for a repository ==  
Line 52: Line 52:
</pre>
</pre>


If you want to chain multiple hooks, a detailed description is available in the gitolite documentation. See the last few paragraphs in the section [http://gitolite.com/gitolite/non-core/#repo-specific-hooks repo-specific-hooks].
If you want to chain multiple hooks, a detailed description is available in the gitolite documentation. See the last few paragraphs in the section [http://gitolite.com/gitolite/non-core#repo-specific-hooks repo-specific-hooks].


== Deactivating multimail for a repository ==
== Deactivating multimail for a repository ==

Latest revision as of 14:19, 12 February 2019

Introduction

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.

ENABLE => [
                          'repo-specific-hooks',

Installing the post-receive hook

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

Now copy git_multimail.py 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 git_multimail.py 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 hook.post-receive         =   multimail
    config multimailhook.from        =   # From address to use, e.g. from@email.com
    config multimailhook.mailinglist =   # Where emails should be sent, e.g. to@email.com

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 hook.post-receive         =   ""
    config multimailhook.from        =   "" # you could also leave this line as it was
    config multimailhook.mailinglist =   "" # you could also leave this line as it was