Trying to write subversion post-commit script to export PHP tu a public folder

1k views Asked by At

I am trying to deploy a PHP application using subversion and post-commit script. I've been looking for how to write post-commit script but i can't get it to work.

Configuration : I have a svn folder installed on my server (OVH) in homeX.XX/svn/test/

My post-commit script should EXPORT to homeX.XX/dev/

I don't know how to write the proper path when using

#!/bin/bash
mkdir dev
chmod 777 dev
svn export svn+ssh://[email protected]/homeX.XX/XXX/svn/test dev

in my POST-COMMIT script. I've been looking for answers but did not find any...

1

There are 1 answers

2
Chris B On BEST ANSWER

From the SVN documentation (here):

The Subversion repository executes hook programs with an empty environment—that is, no environment variables are set at all, not even $PATH.

I've been stung by this problem a few times. Basically the easiest way to write SVN commit hooks, although not very clean, is to hardcode all files and directories that you need as absolute paths.

So in this case, your script would look something like:

#!/bin/bash

# SVN-related variables
svnuser=XXXXX
svnhost=www.xxxx.com
svnpath=/homeX.XX/XXX/svn/test

# Local paths
exportpath=/homeX.XX/dev

# Make export dir if it does not exist
if [ ! -e "$exportpath" ]
then
    mkdir $exportpath
fi

# These permissions are very lenient! Are you sure you want this?
chmod 777 $exportpath

# Do the SVN export
export svn+ssh://$svnuser@$svnhost$svnpath $exportpath