svnsync 时svn post commit-commit 不执行

相关文章随机文章
2,643 &42热门文章1234567891011121314151617181920最新文章bash - SVN Post-Commit Hook error 255 - Stack Overflow
Join the Stack Overflow Community
Stack Overflow is a community of 6.8 million programmers, just like you, helping each other.
J it only takes a minute:
I am trying to create a very simple post-commit hook for a repository I have set up on my server. The script is as follows:
REPOS="$1"
cd /var/www/directory && svn update --username user --password pass
When I run a commit from my SVN client, I get the following error:
post-commit hook failed (exit code 255) with no output.
However, when I run my post-commit hook from cli with sudo bash post-commit, it executes perfectly. Any ideas about what I am doing wrong?
1,08341956
255 means a file wasn't found, try using the absolute path to all files:
REPOS="$1"
cd /var/www/directory && /usr/bin/svn update --username user --password pass
The PATH env variable of the environment in which the post commit hook is running probably isn't set to include wherever the SVN executable lives.
3,60661243
35.5k1497145
Ok, I have figured out the issue. It was a combination of a path issue (as suggested by chown, whose answer I will choose) and a permissions issue. I have written a blog post about the issue (as well as generally getting set up with SVN) which can be found at
1,08341956
Don't forget add #!/bin/sh in your post-commit hook.Use #!/bin/env python if you are using python
Make sure the permission chmod a+x post-commit
Make sure commands in your hook is installed and reachable.
I meet this problem when running SVN in a docker(base on ubuntu) and use a post-commit hook for my Redmine sync:
curl "http://my.redmine.ip/sys/fetch_changesets?id=myproject&key=ETji9KUfs3XxLyyr6cRN"
I got error Warning: post-commit hook failed (exit code 255) with no output.
Then I bash into my docker, run this hook manually and find out that 'curl' is not installed.
I install curl and run hook successfully, but still the same warning when commit.
After add #!/bin/sh like this:
curl "http://my.redmine.ip/sys/fetch_changesets?id=myproject&key=ETji9KUfs3XxLyyr6cRN"
Everything is fine.
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
rev .25290
Stack Overflow works best with JavaScript enabled由于网站上线,需要把新添加功能上传到测试环境进行测试,但由于程序员每天有大量的修改,如果总是登陆服务器手动更新svn工作副本(测试环境)太耗时耗精力,进而增加svn进行commit时,测试环境即时更新的功能。
post-commit脚本:
REPOS="$1"
export LANG=en_US.UTF-8
/usr/bin/svn update /data0/htdocs/xxx.xxx.xx.xxx --username user --password xxxxxx 2&&/tmp/svn_hook_log.txt
echo `whoami`,$REPOS,$REV && /tmp/svn_hook_var.txt
注意字符集问题,本机
LANG=en_US.UTF-8
则脚本中必须加入
export LANG = en_US.UTF-8
否则提交时被报错
更新后报错,脚本执行失败
查看svn_hook_log.txt,内容是svn提示要缓冲明文密码到硬盘,需要输入yes或者no确认,因为得不到脚本回应,所以报错退出。
解决办法:需要在svn服务器配置文件中把store-plaintext-passwords 项前#号去掉并把值改为no
因为需要使用apache身份执行脚本,所以执行
cp -r /root/.subversion/ /var/www/&& #apache用户家目录
vim /var/www/.subversion/servers
&store-plaintext-passwords = no
在工作副本中手动执行了一次svn update后,就发现hooks脚本执行失败,并报错
svn: Can't open file '/data0/htdocs/xxx.xxx.xx.xx/styles/.svn/tmp/entries': Permission denied
一番排查、google后,得出结论,应该是以root身份执行svn update后,.svn文件夹下部分文件夹属主变为root,所以apache身份运行脚本时就没有权限写入了。
解决办法:到报错信息下的.svn路径中,执行chown apache:apache -R *
可能还有别的路径下.svn路径中有问题,在工作副本根下执行 chown apache:apache -R *
阅读(...) 评论()

我要回帖

更多关于 svn post commit 的文章

 

随机推荐