I installed Bonobo Git Server on Windows 2008 R2 Server machine. I created a repository and put post-receive.bat
file in D:\Inetpub\Bonobo.Git.Server\App_Data\Repositories\REPO\hooks
directory.
This is the content of the file:
#!/D/Inetpub/Bonobo.Git.Server/App_Data/Git/sh.exe
BINPATH="/D/Inetpub/Bonobo.Git.Server/App_Data/Git/"
REPOPATH="/D/Inetpub/Bonobo.Git.Server/App_Data/Repositories/REPO/"
GIT="${BINPATH}git"
# Change working directory to the repo root
cd $REPOPATH
read oldrev
read newrev
read refname
branch=$($GIT rev-parse --symbolic --abbrev-ref $refname)
if [ "master" == "$branch" ]; then
echo "receive $branch $refname" >> "${REPOPATH}hookstest.log"
fi
If I execute this file from shell and type "whatever whatever master", then the file "receive master master" is added to hookstest.log
. However, when I push changes to REPO the file is not updated, just as if it wasn't executed.
I have no idea where to look for errors that occurred. Most of the linux tutorials mention that the file must have +x flag. This obviously does not exist on Windows, but I checked and the user that runs Bonobo Git Server in IIS has execution rights on the batch file.
I was also hesitating about the name of the file, so I copied it and removed .bat extension. That did not help either. Any idea how I can get the hook working on the Windows Server?
EDIT
As suggested by @crashmstr I created a batch file (one with extension and one without) that contained:
date /t >> D:\Inetpub\Bonobo.Git.Server\App_Data\Repositories\REPO\testhooks.txt
This did not work either, even though the file was created, when I executed the file manually.
I am not sure what was the problem. In the end I got it working by creating a file D:\Inetpub\Bonobo.Git.Server\App_Data\Repositories\REPO\hooks\post-receive
(no extension) with the following content:
#!/D/Inetpub/Bonobo.Git.Server/App_Data/Git/sh.exe
echo "BEGIN post-receive script"
APPPATH="/D/Inetpub/Bonobo.Git.Server/App_Data"
SVN="/D/csvn/bin/svn"
REPOPATH="$APPPATH/Repositories/REPO"
SVNSYNCPATH="$APPPATH/SVN-sync"
GIT="$APPPATH/Git/git"
mapping["master"]="trunk"
mapping["develop"]="development"
# Change working directory to the repo root
cd $REPOPATH
read oldrev newrev refname
echo "oldrev - $oldrev"
echo "newrev - $newrev"
echo "refname - $refname"
branch=$($GIT rev-parse --symbolic --abbrev-ref $refname)
echo "branch - $branch"
echo ""
if [ "master" == "$branch" ]; then
result=($($GIT diff $oldrev $newrev --name-status))
echo "Detected $((${#result[@]}/2)) changes:"
idx=0
while [ $idx -lt ${#result[@]} ]
do
status=${result[$idx]}
filename=${result[$(($idx+1))]}
echo -n "$status - $filename "
case $status in
"A")
echo "added"
;;
"M")
echo "updated"
;;
"D")
echo "deleted"
;;
"R")
echo "renamed"
;;
"C")
echo "copied"
;;
*)
echo "unknown status"
;;
esac
idx=$(($idx+2))
done
fi
echo ""
echo "END post-receive script"