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

Upcoming events

I will be speaking 06-02-2012: D-Day
I will be speaking 17-02-2012: Techademy Trainingday February
I will be speaking 23-02-2012: Zend Webinar: Git for Subversion Users

Tags

1337 2008 2010 2011 4developers access modifiers accessibility AdaLovelaceDay09 advent agavi agile alfred amsterdam apache api apple article articles atk atkMetaNode audioscrobbler automation azure backwards compatibility barcelona barcodes bash bbc bbq beatstad belgium best practices bittorrent blogging blogs boards of canada book books bughuntday bundle caching cake cal evans calendar career cat cerf certificate cfp clear cms cologne common sense communities community components conference conferences contest continuous integration contribute contribution crisis css custom d-day datetime DbFinderPlugin decorator decorators deployment devdays development directoryindex docblox doctrine documentation download dpc dpc09 dpc10 dpc11 DPC2008 dreamhost drupal dv7 eclipse ed editors efficiency enterprise errors event events expertise ezcomponents facebook finland flickr fork framework frameworks freelance freeze frontend fun game games geoip germany getting real git github gnome-do google google calendar googletalk graceful degradation hack hackers hidden gem hiphop howto hp HR html http i386 ibuildings icann ide ideasofmarch idm imovie indy ingewikkeld integration international php conference internet interview ipad IPC ipc ipc08 ipc10 ipc11se iterm2 javascript jenkins jenkins-php job job openings jobeet john peel joomla joomladays kiva kubuntu launcher launchy left on the web libraries library lighttpd lime linktuesday linux live london loudblog m2ts mac magazines malware mambo marjolein mediterra meeting meme meta methodology micro-financing microframework microsoft migration movie music mysql namespace namespaces netbeans netherlands newsfire nllgg nos odmarco open source opinion ORM osx paradiso paris partnership pavilion pear pecl performance personal pfc10 pfc11 pfcongres pfcongrez pfz photo php php5.3 phpabstract phpazure phpBB phpbb phpbelgium phpbenelux phpbnl10 phpday phpdoc phpdocumentor phpgg phpitalia phpnw phpnw08 phpnw11 phpstorm phptek phptek09 phpuk2009 phpUnderControl phpunit php|architect php|tek podcast politics portability postcrossing presentation presentations private projects protected prototype PSR-0 public python qa qr codes re2c recruiting refactoring review rewrite ruby on rails san francisco schedule scifi script security sensio seven things sfdaycgn sflive2011 shell scripting silex simplexml slides smfony software sogeti solar sound speakers spl ssh standard standards star trek static steer strings stylesheets subversion symfony symfony live Symfony2 symfonycamp symfonyday symfonylive symfonyUnderControlPlugin talk talks techademy technology techportal tek09 telecommuting terratec terrorism testfest testing textmate textpattern the right tool timeout tips tld todo tomas tools training twig uncon unet usability usergroup validation vhost video vim vinyl virus warp webinar weblogging webservices wiki windows winphp women wordpress work workshop world world of warcraft wpi writing wunderlist xml xpath xsd yara year youtube zc11 ZCE zemanta zend zend framework zend server zend studio zendcon Zend_Form zite
© 2004 - 2012 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