如何让 Subversion (SVN) 在签到时发送电子邮件?
我一直发现签入(提交)邮件对于跟踪其他人在代码库/存储库中所做的工作非常有用。 如何设置 SVN 在每次提交时通过电子邮件发送通讯组列表?
我在 Windows 上运行客户端,在 Linux 上运行 Apache Subversion 服务器。 不过,下面针对不同平台的答案可能对其他人有用。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(16)
检查svn-mod-email包="nofollow">这里。 svn-mod-email 是一个强大的 SVN 电子邮件通知管理工具,以 Debian 存档形式提供。 它易于安装、配置和使用。
Check the svn-mod-email package described here. The svn-mod-email is a powerful tool for SVN email notifications management that is delivered as a Debian archive. It's easily to install, configure and use.
您可以使用 buildbot。 该工具可以在签到时执行任意操作。 它是一个功能齐全的持续集成系统,但如果您只需要电子邮件,它当然可以处理。 它具有适用于包括 SVN 在内的各种 SCM 的插件。
You could use buildbot. It's a tool that can take arbitrary action whenever a check-in occurs. It's a full featured continuous integration system but if you just want emails it can certainly handle that. It has plug-ins for a variety of SCMs including SVN.
在特定 subversion 分支的“hooks”目录中,有 9 个模板文件可以帮助您入门。
关键点:subversion 在重命名之前不会执行任何文件。 要让 post-commit.tmpl 在 unix 下执行,请将其重命名为“post-commit”。 在 Windows 下,将其重命名为“post-commit.bat”或“post-commit.exe”。 如果文件名为“post-commit.tmpl”或“post-commit.sh”等,Subversion 将不会执行该文件。
另外,请确保该文件可由运行 subversion 的同一用户执行。
In the "hooks" directory of your specific subversion branch there are 9 template files to get you started.
Key point: subversion will not execute any of the files until they are renamed. To get post-commit.tmpl to execute under unix, rename it "post-commit". Under Windows, rename it to "post-commit.bat" or "post-commit.exe". Subversion will not execute the file if it is named "post-commit.tmpl" or "post-commit.sh" or the like.
Also, make sure that the file is executable by the same user that runs subversion.
我使用类似于此的提交后脚本 一个。
它会发送一封漂亮的 HTML 电子邮件。 我对其进行了一些更新,其中以红色突出显示了已删除的代码,并以蓝色突出显示了添加的代码。
I use a post-commit script similar to this one.
It's sends a nice HTML email. I updated it some where it highlights code that was removed in red and highlights code that was added in blue.
我在 Linux 服务器上分 3 步完成了此操作:
创建邮件列表 (
[email protected]
)并将人员添加到列表中。编辑
/path_to_your_svn/svn/hooks/svn-notify/mailer.conf
/path_to_your_svn/svn/hooks/post-commit
文件中:/path_to_your_svn/svn/hooks/svn-notify/mailer.py commit "$REPOS" "$REV" /path_to_your_svn/svn/hooks/svn-notify/mailer.conf
I did it on Linux server in 3 steps:
Create a mailing list (
[email protected]
) and add people to the list.Edit
/path_to_your_svn/svn/hooks/svn-notify/mailer.conf
/path_to_your_svn/svn/hooks/post-commit
file:/path_to_your_svn/svn/hooks/svn-notify/mailer.py commit "$REPOS" "$REV" /path_to_your_svn/svn/hooks/svn-notify/mailer.conf
什么平台?
在 Mac OS X 上,我安装了 msmtp 并在存储库中的钩子下创建了一个提交后脚本。 需要为
svn
(或www
)用户设置 .msmtprc 文件。使
{root of repository}
和{list ofrecipients}
专门满足您的需求。 注意我使用了 UTF-8,因为瑞典有一些特殊字符 (åäö)。What platform?
On Mac OS X I have installed msmtp and created a post-commit script under hooks in the repository. A .msmtprc file needs to be setup for the
svn
(orwww
) user.Make
{root of repository}
and{list of recipients}
specific for your needs. Note I have used UTF-8 because we have some special characters here in Sweden (åäö).Subversion 源代码中包含一个用 Perl 编写的(大型)示例(可以是 在此处查看)。
There is a (large) example written in Perl included in the Subversion source (it can be viewed here).
还有 SVNMailer,它可以在 Linux 上运行。
Also SVNMailer, which works on Linux.
这里有一个关于提交后挂钩的相关问题。 就我个人而言,我更喜欢将消息发送到可以从中获取 RSS 源的地方,因为每次提交一封电子邮件都会很快使我的收件箱超载。
There's a related question here on post-commit hooks. Personally, I prefer to send a message to something I can get an RSS feed from, as an email-per-commit would overload my inbox pretty quickly.
在 RSS 上支持 @Matt Miller饲料。
有一个名为 WebSVN 的有用工具,它提供每个存储库和单个分支/标签/文件夹的 RSS 提要以及完整提交消息。 它也是一个很棒的网络界面,可以快速查看文件历史记录和提交/差异,而无需运行更新并打开您选择的编辑器。
Seconding @Matt Miller on RSS feeds.
There's a useful tool called WebSVN that offers RSS feeds of every repository and individual branches/tags/folders with full commit messages. It's also a great web interface for quickly looking at file histories and commits/diffs without having to run an update and open your editor of choice.
正如其他人所说,“什么平台”。 在 Windows 上,我使用“blat”(一个免费的命令行 SMTP 邮件程序)以及一个提交后文件和另一个批处理文件来执行此操作。
提交后看起来像这样:(只是调用另一个批处理文件)
并且mail.bat看起来像这样:
编写SVN钩子时最大的问题是你可能基本上没有环境设置 - 没有exe路径,没有临时路径等.不过也许这在最近的 SVN 版本中有所改进。
As someone else said, 'what platform'. On Windows I've used 'blat', which is a freebie command line SMTP mailer to do this, along with a post-commit and another batch file.
The post commit looks like this: (Just calls another batch file)
And mail.bat looked like this:
The biggest gotcha in writing SVN hooks is that you might have basically NO environment set-up - no exe path, no temp path, etc. Though maybe that's improved in more recent SVN builds.
1) 使用 sudo apt-get 在 svn 服务器上安装 svnnotify
2) 使用存储库的 post-commit 挂钩(阅读 svn 网站上的 post-commit 挂钩)
3) 打开 post-commit 挂钩文件并粘贴以下代码以发送电子邮件使用 smtp 服务器。
使用 smtp 非常简单,因为您不需要配置 sendmail。
4)确保\(换行符)之后没有多余的空格。
1) Install svnnotify on a svn server using sudo apt-get
2) Use post-commit hook of your repo (read on post-commit hooks on svn website)
3) Open post-commit hook file and paste following code to send an email using smtp server.
Using smtp is straight forward since you don't need to configure sendmail.
4) Make sure after \ (line break) you don't have an extra space.
VisualSVN Server 有有用的提交电子邮件通知挂钩
VisualSVNServerHooks.exe
。 它支持彩色差异,并且仅当提交影响某些存储库路径时才可以发送提交通知。请参阅“在 VisualSVN 服务器中配置电子邮件通知”。
VisualSVN Server has useful commit e-mail notification hook
VisualSVNServerHooks.exe
. It supports colored diffs and can send commit notifications only when commit affects certain repository path.See "Configuring Email Notifications in VisualSVN Server".
查看独立的 Subversion Notify 工具(仅限 Windows!)
它可以在提交时发送电子邮件等等!
Have a look at the standalone Subversion Notify tool (Windows only!)
It can do emailing on commit and also much more!
您需要熟悉 存储库挂钩,特别是 提交后挂钩。
You'll want to familiarize yourself with repository hooks, particularly the post-commit hook.
您使用 提交后钩子。
下面是一个示例 Ruby 脚本,它在每次提交后发送一封电子邮件: commit-email.rb
You use the post-commit hooks.
Here's a sample Ruby script that sends an email after each commit: commit-email.rb