trac-post-commit-hook on DreamHost

Trac is now working on DreamHost, but I wanted to use the integration with Subversion by having the commits that reference a Trac issue automatically be shown in Trac. On DreamHost, this is slightly different because of the different Python environment.

Now that I have Trac working on DreamHost, I want to also get the trac-post-commit-hook working, so that commits will automatically show up in Trac. Using the default instructions unfortunately does not work fully, since the installation by DreamTracInstall which I wrote about earlier does some specific things (like installing a completely new Python environment) that the default instructions don't take into consideration. It's not that hard though, as the basic steps are the same. First of all, you'll need the script. Since DreamTracInstall currently installed 0.9.6, you need to use that version. You put this script in some location on the server. I put mine in /home/skoop/trac_sites/trac_hooks (I know, maybe not the best location, but it keeps my home dir clean). Now, using an SSH connection, go to your subversion environment for which you want to install the hook (/home/myusername/svn/myproject/hooks). Copy the post-commit template (post-commit.tmpl) to 'post-commit' (no quotes). Your post-commit script will now be found. Comment out the e-mail alert (unless you want to use it, in that case chance the e-mailaddress). Now, add the following:
LOG=`/usr/bin/svnlook log -r $REV $REPOS`
AUTHOR=`/usr/bin/svnlook author -r $REV $REPOS`
TRAC_ENV='/home/myusername/trac_sites/myproject/'
HOME='/home/myusername' 
export PYTHONPATH="$HOME/packages/lib/python2.3/site-packages"
export LD_LIBRARY_PATH="$HOME/packages/lib" 
export PATH="$HOME/packages/bin:$PATH"

/home/myusername/packages/bin/python2.3 /home/myusername/trac_sites/trac_hooks/trac-post-commit-hook \
 -p "$TRAC_ENV"  \
 -r "$REV"       \
 -u "$AUTHOR"    \
 -m "$LOG"
Ensure to edit the paths to your specific situation. Now, you need to one last thing. You need to ensure that your trac database directory and file are writable by the webserver user. I am sure we're opening up a can of security worms here, but it seems there's no easy way around it, except if you want to somehow start writing proxy scripts which are executed as another user. So go to /home/myusername/trac_sites/myproject/ and chmod -R 777 db Now you should be all set. Commit something to your repository, with in the commit message something like re #1 (this has to be an existing issue number of course) ... in the Trac web interface, you should now see the commit message with a reference to the changeset listed with the issue you mentioned. Enjoy!
Add comment

Comments

gravatar Kelan Champagne: I wrote a post on my blog about how I got around the permissions issue without making my trac project publicly readable/writable. I essentially wrote the "proxy script" you alluded to in your post. Details are here: http://yeahrightkeller.com/2009/06/02/trac-svn-post-commit-hook-on-dreamhost/
June 7, 2009

Php5_zce_logo

not tested in IE


Upcoming events

I will be attending 17-04-2010: Pfcongres

Tags

1337 2008 2010 4developers accessibility AdaLovelaceDay09 advent agavi agile amsterdam apache apple article articles atk atkMetaNode audioscrobbler backwards compatibility barcelona bbc bbq beatstad belgium best practices bittorrent book books bughuntday caching cake cal evans cat cerf certificate cfp clear cms cologne common sense community conference conferences continuous integration crisis css custom datetime DbFinderPlugin decorator decorators deployment devdays development directoryindex documentation download dpc dpc09 DPC2008 dreamhost dv7 eclipse ed efficiency enterprise event events expertise ezcomponents facebook flickr framework frameworks freeze frontend fun games germany getting real google googletalk graceful degradation hack hackers hidden gem hiphop howto hp html http ibuildings icann ide imovie indy internet IPC ipc ipc08 javascript jobeet john peel joomla kubuntu left on the web lighttpd lime linux live london loudblog m2ts mac malware mambo marjolein meeting meme meta methodology microsoft movie music mysql namespace namespaces netbeans netherlands nllgg odmarco open source opinion ORM osx paradiso pavilion pear performance personal pfcongrez photo php phpabstract phpBB phpbb phpbelgium phpbenelux phpbnl10 phpgg phpitalia phpnw phpnw08 phptek phptek09 phpuk2009 phpUnderControl phpunit php|architect php|tek podcast politics portability postcrossing presentation presentations public qa recruiting refactoring review rewrite ruby on rails schedule script security seven things sfdaycgn simplexml slides smfony software sogeti solar sound standard standards static steer strings subversion symfony symfonycamp symfonyday symfonyUnderControlPlugin talk talks technology techportal tek09 telecommuting terratec terrorism testfest testing textpattern tips tld tomas unet usability usergroup validation vhost video vinyl virus warp weblogging wiki women work world world of warcraft writing xml xpath xsd yara year youtube ZCE zemanta zend zend framework zend server zend studio Zend_Form
© 2004 - 2010 Stefan Koopmanschap + Powered by Symfony, photos powered by Flickr, links powered by Delicious, Shanghai smilies by Iconbuffet. Feeds: rss / atom. Left on the Web v4.4.0.1