Context
A few weeks back i decided to make a web site to manage RPG games for people who cannot meet IRL at the request of some friends.
At first, since I was the only one doing any work on the site I did not really care about versionning the code. However came a time where I ended up asking a friend who can do graphics for help in doing the design and layout of the page. After exluding the HTML code from the PHP code in pretty much everywhere came the problem with 2 people working on the same files without versionning… After 2 or 3 incidents I just decided to use my svn server to version the files for the web site.
However, when you version your code it is not automatically published and you have to use post-commit hooks. And because you do not want your website to hold the svn administration folders you cannot make the website on the web server a checkout folder. Thus you need to rely on svn export.
Configuration
The server is setup with SVN loaded into Apache and both SVN server and Apache server running as services under the account ‘local system’ on a Windows machine. Apache was running with the ‘Local System’ account.
Problem
Thus i started implementing my post commit hook to export the website after each commit. And it did not work.
Resolution
Solving this issue took me quite some time from getting help on IRC or from Google. It also happened because I am not well versed in the technology I use here. Here is the list of thing I tried:
- Providing a username and password to the svn export command. Unsuccessful (still do not know why).
- Making the repository readable for everyone. Unsuccessful (I guess it is still linked to point 1).
- Launching Apache manually. Successful… but not really efficient (due to the use I do of the server (lots of tests)).
Conclusion
To finally get this to work I did the following:
- Create a user for Apache.
- Launch a command prompt running as Apache
- Run the svn export command, svn asked me for a user / password and I provided svn with that information.
And that seems to have done it.
And for information here is the command i used in the post commit hook file (post-commit.bat):
svn export –force reporitoryURL websiteFolderPATH
I however still have unresolved issues:
- How the heck do I provide a username / password to svn through a command prompt ? (Error: ~ file path not found)
- Why allowing read access to the repository did not solve the problem ? (Is the local system account unable to access the repository url?) (Do I need to provide the –non-interactive switch?)
Once I have a bit of time I’ll try one of the few things that need to be tried and update / comment this post.
Another experiment after that
Because I also have a subversion repository on my laptop to version the file I work on (I hate having the same files with a version extension, it is just cluttering the folders) and I wanted to backup my versionned files automatically to a network share, once again I had to implement post-commit hooks.
However this time, SVN runs standalone without being integrated into Apache. And this time the export had to be done on a network share mapped on my computer. Because subversion removes all the pathing information before running hooks you have to provide the full network path or remap the drive to your computer before running the export and you also need to have write access for the SVN account to that share (or run the command as another user (no idea how to do that yet))
In the hope that it will help someone, someday.
Chryzo