Search
Close this search box.

Setting up hooks for Subversion Server

Collaboration is a very difficult task and it becomes worse in a software development project. Subversion helps you to manage collaboration in a very efficient way while working on a software development project in an environment full of developers from different team.
We were working on the Moodle module development project and as the team started becoming bigger and bigger, we decided that we will have to setup hooks in SVN to trigger emails to all the team members whenever a commit is done by any of the contributors.

When you create a new subversion repository it creates a hooks directory. This hooks directory has the templates of hooks. Each file name reflects the type of trigger which causes that file to execute. For example, a file name post-commit.tmpl is a template for a file which will be executed after a commit has happened. A file which will be executed post a commit action is performed by a user should be named post-commit.
And this is what we were looking for. Usually, these files are used for executing another file which performs the action but you can use these files to perform some basic functions as well.
Depending on when do you want the action performed, you need to rename the file action.tmpl to action. For example, I renamed post-commit.tmpl to post-commit because I wanted to send an email after commit.
Rest was easy because of this post; which talks about the PHP script which can be used to send an email. The only thing left after this was making sure that the post-commit hook calls the PHP script to send the email and passes the correct variables and this was achieved using this line in post-commit hook.

php /path/to/commitEmail.php “$REPOS” “$REV”

You just need to make sure that you have PHP CLI installed.

Share on:

You may also like

en_ie

Subscribe To Our Newsletter