提交后钩子在svn提交时产生错误,但在命令行上手动运行时可以工作 [英] post-commit hook produces error on svn commit but works when run on manually on command line

查看:281
本文介绍了提交后钩子在svn提交时产生错误,但在命令行上手动运行时可以工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我当前正在尝试为我的Subversion存储库设置提交后挂钩,以发送电子邮件通知. 我正在使用Subversion 1.7.8.我的提交后挂钩脚本如下:

I am currently trying to set up the post-commit hook for my subversion repository to send a email notifications. I am using subversion 1.7.8. My post-commit hook script is as follows:

#!/bin/sh

REPOS="$1"
REV="$2"

"$REPOS"/hooks/mailer.py commit $REPOS $REV "$REPOS"/mailer.conf

当我进行提交时,会产生以下错误消息:

When I make a commit the following error message is produced:

Traceback (most recent call last):
  File "/lib/python2.7/site.py", line 563, in <module>
    main()
  File "/lib/python2.7/site.py", line 545, in main
   known_paths = addusersitepackages(known_paths)
  File "/lib/python2.7/site.py", line 278, in addusersitepackages
   user_site = getusersitepackages()
  File "/lib/python2.7/site.py", line 253, in getusersitepackages
   user_base = getuserbase() # this will also set USER_BASE
  File "/lib/python2.7/site.py", line 243, in getuserbase
   USER_BASE = get_config_var('userbase')
  File "/lib/python2.7/sysconfig.py", line 521, in get_config_var
   return get_config_vars().get(name)
  File "/lib/python2.7/sysconfig.py", line 420, in get_config_vars
   _init_posix(_CONFIG_VARS)
  File "/lib/python2.7/sysconfig.py", line 299, in _init_posix
raise IOError(msg)
IOError: invalid Python installation: unable to open //include/python2.7/pyconfig-32.h (No such file or directory)

关于此错误的奇特之处在于,当我在命令行(使用适当的参数)上运行提交后的自我时,没有错误产生,并且我收到了所需的电子邮件通知.这使我认为该错误与我的mailer.conf文件无关.

The peculiar thing about this error is that when I run post-commit myself on the command-line (with the appropriate arguments) no errors are produced, and I receive the desired email notification. This makes me think the error is not related to my mailer.conf file.

有人知道导致此错误的原因是什么吗?

Does anyone have any idea what could be causing this error?

谢谢, 杰米.

更正:

我认为在root用户下运行svnserve可以在本地解决该问题,但是经过进一步的实验,我意识到这是错误的.如果使用file://语法检出了项目,则post-commit在本地计算机上有效,但是如果使用svn://语法检出了项目,则post-commit将失败.

I thought that running svnserve under root fixed the problem locally but after further experimentation I realise that this is wrong. post-commit works on the local machine if the project was checked out using the file:// syntax but fails if checked out using the svn:// syntax.

因此,仅当svnserve尝试运行提交后的问题时,才出现问题,无论它是否在root用户下运行,或者客户端在同一台机器上还是另一台机器上.

Therefore, the problem only arises when svnserve tries to run post-commit, regardless of whether it is running under root or not, or the client is on the same or a different machine.

推荐答案

钩子不触发的原因可能有很多:

There could be many possible reasons why your hook isn't firing:

  • 出于安全原因,在未设置任何环境变量的情况下运行Subversion挂钩脚本.因此,请在挂钩中设置环境变量,并使用绝对路径来运行应用程序
  • 网络驱动器映射是特定于用户的.确保运行SVN服务器的用户帐户存在驱动器
  • 钩子不是从hooks/文件夹执行,而是从根服务器的文件夹执行
  • For security reasons, Subversion hook scripts are run without any environment variables being set. So, set the environment variables in the hook, and use absolute paths for running applications
  • Network drive mappings are user specific. Ensure that the drives exist for the user account under which the SVN server is running
  • Hooks don't execute from the hooks/ folder, they execute from the root server's folder

更多信息:

  • Subversion Book: Implementing Repository Hooks
  • Debugging Subversion Repository Hooks

希望这会有所帮助.

这篇关于提交后钩子在svn提交时产生错误,但在命令行上手动运行时可以工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆