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

瘦欲@ 提交于 2019-12-12 05:59:57

问题


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://XXXXX@www.xxxx.com/homeX.XX/XXX/svn/test dev

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


回答1:


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


来源:https://stackoverflow.com/questions/5154006/trying-to-write-subversion-post-commit-script-to-export-php-tu-a-public-folder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!