The scenario is like this. I have checked out copy on my local machine. Now 
whenever I merge the code the script which ideally should get executed doesn't 
execute at all. I modified the script as given below. Only changes I have done 
is removed IF loops and it works fine. The permissions are the same.
-rwxrwx--- 1 svn apache 616 Jul 29 12:41 post-commit
User/Group for apache is svn:apache
#!/bin/sh -x
REPOS="$1"
DIR=`/usr/bin/svnlook changed  $REPOS|head -n1 | cut -d'/' -f2`
Method=`/usr/bin/svnlook changed  $REPOS|head -n1 | awk '{print $1}'`
if [ $Method == A ]  &&  [ $DIR == QA ]; then
TID=`/usr/bin/svnlook changed  $REPOS | head -n1 | cut -d"/" -f3`
/usr/bin/ssh user@172.16.3.2 "cd /newdeploy/Project//config ; cap deploy:php 
tagid=$TID"
elif [ $Method == M ]  &&  [ $DIR == QA ]; then
TID=`/usr/bin/svnlook changed  $REPOS | head -n1 | cut -d"/" -f3`
/usr/bin/ssh user@172.16.3.2 "cd /newdeploy/Project/config ; cap deploy:php 
tagid=$TID"
elif [ $Method == D ]; then
exit
fi

Regards,Himanshu Raina
--- On Fri, 29/7/11, Cooke, Mark <mark.co...@siemens.com> wrote:

From: Cooke, Mark <mark.co...@siemens.com>
Subject: RE: Post Commit Hook Script !!
To: "Himanshu Raina" <raina_himan...@yahoo.com>, users@subversion.apache.org
Date: Friday, 29 July, 2011, 12:51 PM

Hello,

> -----Original Message-----
> From: Himanshu Raina [mailto:raina_himan...@yahoo.com] 
> Sent: 29 July 2011 08:17
> To: users@subversion.apache.org
> Subject: Post Commit Hook Script !!
> 
> Hi,
> 
> The post-commit script isn't getting executed whenever code 
> is merged from trunk to tags. Whenever the code needs to be 
> deployed the code is copied from trunk to tags. The script 
> runs fine when executed on the server but doesn't get invoked 
> whenever a commit is done.

That sounds like a permissions issue ~ you say "the script runs fine
when executed on the server" but as which user? Remember that the server
almost certainly runs as a different user (depending on your setup) and,
usually, that user has restricted access and rights.

~ mark c

> svn co http://mydomain.com/svn/Project/Trunk/Code 
> http://mydomain.com/svn/Project/Tags/QA/Code_2424
> 
> I'm using capistrano for deploying code on my server. The 
> post commit hook is given below
> 
> #!/bin/sh
> ##############################################################
> ###############################
> REPOS="$1"
> 
> 
> DIR=`/usr/bin/svnlook changed  $REPOS | /usr/bin/head -n1 | 
> /bin/cut -d'/' -f2`
> 
> 
> Method=`/usr/bin/svnlook changed  $REPOS | /usr/bin/head -n1 
> | /bin/awk '{print $1}'`
> 
> 
> /bin/echo $REPOS $DIR $Method
> #################---Addition---#####################
> if [ "$Method" == "A" ] && [ "$DIR" == "QA" ]; then
> 
> 
> TID=`/usr/bin/svnlook changed  $REPOS | /usr/bin/head -n1 | 
> /bin/cut -d"/" -f3`
> 
> 
> echo "Do you wish to deploy the code on QA server"
> read input
> if [[ $input == '' ]]; then
> echo "Usage: $0 <Y/N>"
> elif [ $input == Y ]; then
> /usr/bin/ssh user@172.16.3.2 "cd /newdeploy/Project/config ; 
> /usr/bin/cap deploy:php tagid=$TID"
> elif [ $input == N ]; then
> exit
> fi
> ##############---Modification---################################
> elif [ "$Method" == "M" ] && [ "$DIR" == "QA" ]; then
> 
> 
> TID=`/usr/bin/svnlook changed  $REPOS | /usr/bin/head -n1 | 
> /bin/cut -d"/" -f3`
> 
> 
> echo "Do you wish to deploy the code on QA server"
> read input
> if [[ $input == '' ]]; then
> echo "Usage: $0 <Y/N>"
> elif [ $input == Y ]; then
> /usr/bin/ssh  user@172.16.3.2 "cd /newdeploy/Project/config ; 
> /usr/bin/cap deploy:php tagid=$TID"
> elif [ $input == N ]; then
> exit
> fi
> ################---Deletion##############################
> elif [ "$Method" == "D" ]; then
> 
> 
> exit
> 
> 
> fi
> ######################################################
> 
> 
> Regards,
> Himanshu
> 

Reply via email to