[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Post Commit Hook Script !!

From: Himanshu Raina <raina_himanshu_at_yahoo.com>
Date: Fri, 29 Jul 2011 14:08:04 +0530 (IST)

Well the interactive part has been removed. Moreover, there exists null keys between the servers so it won't prompt for password. The current issue that I'm facing is that it gives the following error on execution
Warning: post-commit hook failed (exit code 255) with output:+ /usr/bin/ssh -l root 192.168.2.60 'cd /deploy/Project/config; /usr/bin/cap deploy:php tagid=Code1'Host key verification failed.
The deployment script has an environment variable set which takes the tagid as specified in the command line. The set is as follow
From my machine I do commit, the changes are updated in the repository on svn server. The hook script gets invoked and connects to another server where deployments scripts are available and the script in turn connects to different destination servers. The entire process uses SSH and I am using null keys for the time being.
Regards,Himanshu

--- On Fri, 29/7/11, Ryan Schmidt <subversion-2011a_at_ryandesign.com> wrote:

From: Ryan Schmidt <subversion-2011a_at_ryandesign.com>
Subject: Re: Post Commit Hook Script !!
To: "Himanshu Raina" <raina_himanshu_at_yahoo.com>
Cc: users_at_subversion.apache.org, "MarkCooke" <mark.cooke_at_siemens.com>
Date: Friday, 29 July, 2011, 1:34 PM

On Jul 29, 2011, at 02:43, Himanshu Raina wrote:

> 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}'`

Your original script showed you using absolute paths to head, cut, awk, which is what you should be doing because the hook script runs with an empty environment and who knows what the $PATH is.

> if [ $Method == A ]  &&  [ $DIR == QA ]; then
>
> TID=`/usr/bin/svnlook changed  $REPOS | head -n1 | cut -d"/" -f3`
>
> /usr/bin/ssh user_at_172.16.3.2 "cd /newdeploy/Project//config ; cap deploy:php tagid=$TID"

ssh? How will the authentication occur? Obviously if it prompts you for a password there's no way to respond to that prompt. So you'd need ssh keys. Make sure they're in the correct directory for the user that this hook script is running under.

> elif [ $Method == M ]  &&  [ $DIR == QA ]; then
>
> TID=`/usr/bin/svnlook changed  $REPOS | head -n1 | cut -d"/" -f3`
>
> /usr/bin/ssh user_at_172.16.3.2 "cd /newdeploy/Project/config ; cap deploy:php tagid=$TID"
>
> elif [ $Method == D ]; then
>
> exit
>
> fi
Received on 2011-07-29 10:38:57 CEST

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.