简体   繁体   English

提交后钩子在svn提交时产生错误,但在命令行上手动运行时有效

[英]post-commit hook produces error on svn commit but works when run on manually on command line

I am currently trying to set up the post-commit hook for my subversion repository to send a email notifications. 我目前正在尝试为我的Subversion存储库设置提交后挂钩,以发送电子邮件通知。 I am using subversion 1.7.8. 我正在使用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)

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. 这使我认为该错误与我的mailer.conf文件无关。

Does anyone have any idea what could be causing this error? 有谁知道什么可能导致此错误?

Thanks, Jamie. 谢谢杰米。

CORRECTION: 更正:

I thought that running svnserve under root fixed the problem locally but after further experimentation I realise that this is wrong. 我以为在根目录下运行svnserve可以在本地解决该问题,但是经过进一步的试验,我意识到这是错误的。 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. 如果使用file://语法检出了项目,则post-commit在本地计算机上工作,但是如果使用svn://语法检出,则项目失败。

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

There could be many possible reasons why your hook isn't firing: 您的钩子未触发的可能原因有很多:

  • For security reasons, Subversion hook scripts are run without any environment variables being set. 出于安全原因,在未设置任何环境变量的情况下运行Subversion挂钩脚本。 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 确保存在用于运行SVN服务器的用户帐户的驱动器
  • Hooks don't execute from the hooks/ folder, they execute from the root server's folder 挂钩不从hooks/文件夹执行,而是从根服务器的文件夹执行

More info: 更多信息:

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM