bash SVN 提交后挂钩错误 255
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7841591/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
SVN Post-Commit Hook error 255
提问by Brendon Dugan
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=""
REV=""
cd /var/www/directory && svn update --username user --password pass
When I run a commit from my SVN client, I get the following error:
当我从 SVN 客户端运行提交时,出现以下错误:
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?
但是,当我使用 sudo bash post-commit 从 cli 运行我的 post-commit 挂钩时,它执行得很好。关于我做错了什么的任何想法?
采纳答案by chown
255 means a file wasn't found, try using the absolute path to all files:
255 表示未找到文件,请尝试使用所有文件的绝对路径:
REPOS=""
REV=""
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.
运行提交后挂钩的环境的 PATH env 变量可能未设置为包括 SVN 可执行文件所在的位置。
回答by Brendon Dugan
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 http://brennydoogles.wordpress.com
好的,我已经想通了这个问题。这是路径问题(正如 chown 所建议的,我会选择他的答案)和权限问题的组合。我写了一篇关于这个问题的博客文章(以及通常使用 SVN 进行设置),可以在http://brennydoogles.wordpress.com上找到
回答by user3790229
- Don't forget add
#!/bin/shin your post-commit hook.Use#!/bin/env pythonif you are using python - Make sure the permission
chmod a+x post-commit - Make sure commands in your hook is installed and reachable.
- 不要忘记添加
#!/bin/sh你的提交后钩子。#!/bin/env python如果你使用的是 python - 确保权限
chmod a+x post-commit - 确保钩子中的命令已安装且可访问。
I meet this problem when running SVN in a docker(base on ubuntu) and use a post-commit hook for my Redmine sync:
我在 docker(基于 ubuntu)中运行 SVN 时遇到了这个问题,并为我的 Redmine 同步使用了提交后钩子:
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.
我有错误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.
然后我 bash 进入我的 docker,手动运行这个钩子,发现没有安装 'curl'。
I install curl and run hook successfully, but still the same warning when commit.
我安装 curl 并成功运行钩子,但提交时仍然出现相同的警告。
After add #!/bin/shlike this:
#!/bin/sh像这样添加后:
#!/bin/sh
curl "http://my.redmine.ip/sys/fetch_changesets?id=myproject&key=ETji9KUfs3XxLyyr6cRN"
Everything is fine.
一切安好。
回答by Mac
Also if the svn server is running under apache, and the operating system is running SElinux, remember to give apache permission to run the script, as in:
另外如果svn服务器运行在apache下,而操作系统运行的是SElinux,记得给apache运行脚本的权限,如下:
% chcon -t httpd_exec_t /home/svn/repos/hooks/post-commit
% chcon -t httpd_exec_t /home/svn/repos/hooks/post-commit

