Using subversion post-commit hooks with Dreamhost

Subversion is a great tool for managing code. It’s even better now that Dreamhost offers it and you get 20+gb to store stuff. I’ve been ubsing subversion to version control a web app that I’m working on. What I wanted to do was to be able to commit changes to my code repository and then have the updated files automatically deployed to the test site. This is pretty easy with subversion’s hooks. Just add an executable post-commit hook with the following:

#!/bin/sh
/usr/bin/svn export –username myusername –password mypassword –force http://youdomain.com/repository /path/to/deploy

Easy enough? Kinda. If you’re trying to get this working with Dreamhost, make sure to change the deploy directory permissions to 777 since the user dhapache is actually writing to the directory. Spent quite a while looking for solutions on the web last night and after talking to Dreamhost customer service we finally found out that the directory permissions were causing the problem. Just thought I’d blog about it in hopes of helping someone else. :)

6 Responses to “Using subversion post-commit hooks with Dreamhost”

  1. April 24th, 2006 | 10:21 pm

    Ah yes, SVN is pretty rad. Now, only if it’d notify me on every commit… that’d be swell.

  2. April 24th, 2006 | 10:26 pm

    You can add a post-commit to email you after every commit… I think there’s even a script supplied by default.

  3. Jesse
    November 6th, 2006 | 3:34 pm

    Awesome, who woulda thought I’d find someone blogging about something so obscure. Totally had the same problem, thanks!

    Jesse.

  4. Jesse
    November 6th, 2006 | 3:36 pm

    Ah wait, spoke too soon. I’m having the problem where the post-commit email hook is either not running or not succeeding =[

  5. December 15th, 2006 | 2:44 am

    […] After reading a myriad of solutions (like here and here ), I found the Dreamhost wiki entry the most helpful. So without further adieu, here’s a small, quick and dirty tutorial on how to automagically get post-commit working with Subversion on your Dreamhost account. […]

  6. A different Jesse
    October 12th, 2007 | 9:44 am

    Thanks for the post - was a big help configuring the post-commit on my own server. I had a little trouble getting it to work at first, but it was a permissions problem as usual. A simple:

    chown -R www-data:developers /path/to/deploy
    chmod -R 775 /path/to/deploy

    solved the problem for me. In my case, www-data is the default apache2 user on my Debian distro; developers is the group I created - well, for my developers. I’ve played with svn on Dreamhost a little as well; I wonder if it’s possible to get them to configure the permissions similarly with dhapache as the user instead of the chmod 777? Something about that makes me a little nervous…

Leave a reply