git Git钩子发送有关回购更改的电子邮件通知

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/552360/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 06:10:05  来源:igfitidea点击:

Git hook to send email notification on repo changes

gitgithooks

提问by Head

How do I configure the appropriate Git hook to send a summary email whenever a set of changes is pushed to the upstream repository?

我如何配置适当的 Git 挂钩以在将一组更改推送到上游存储库时发送摘要电子邮件?

采纳答案by mwalling

Another, more modern way to do this is with git-multimail, as suggested by Chordsbelow.

另一种更现代的方法是使用git-multimail,如下面的Chords所建议的那样。



This is how you did it in 2009.

这就是你在 2009 年所做的。

You could add something like thisto your post-receive hook in $GITDIR/hooks, or use the script in the contrib directory of the source (Available here)

你可以添加类似这样您在$ GITDIR /挂钩后收到钩,或源的contrib目录使用脚本(点击此处下载)

回答by Matija

Here is the simplest solution I've found:

这是我找到的最简单的解决方案:

1) Log in to your gitHub account on github.com

1)登录到您的GitHub的帐户github.com

2) In the main tab click on Settings

2)在主选项卡中单击设置

3) From the main navigation choose Service Hooks

3) 从主导航中选择Service Hooks

4) From Available Hooks choose Email

4) 从可用挂钩中选择电子邮件

5) Fill in your email address in field Address

5)在字段地址填写您的电子邮件地址

6) Check the checkbox Send from Author

6) 选中从作者发送的复选框

7) Check the checkbox Active

7) 选中复选框活动

8) Click on Update Settings

8)点击更新设置

Optional: You can click on Test Hookfor testing, check your inbox you should receive email.

可选:您可以单击Test Hook进行测试,检查您应该收到电子邮件的收件箱。

Also there are images made according to the process:

还有按照流程制作的图片:

enter image description here

在此处输入图片说明

enter image description here

在此处输入图片说明

enter image description here

在此处输入图片说明

enter image description here

在此处输入图片说明

And now for the grand finalI have the answer which is tested and approved at my side.

现在,对于总决赛,我得到了在我身边经过测试和批准的答案。

How to send email to ALL development team members, when gitHub's Service Hooks->Email allows only at most 2 recipients }.

当 gitHub 的 Service Hooks->Email 最多只允许 2 个收件人时,如何向所有开发团队成员发送电子邮件 }.

The answer is combination of Service Hook->Email @ GitHub && Google groups

答案是Service Hook->Email @GitHub && Google 组的组合

  1. First login to your google account
  2. Go to Google Groupsand at the top click on Create Group
  3. Type in Group Name, Group email address (will copy/paste into GitHub Service Hook->Email Address), Group description
  4. After that hit Create button at the top, your new group should be created now
  5. After that in the menu to the left hit Invite membersand type in the email addresses of your team mates
  6. After that hit Send invites(when your members accept invitation) they are now formally members of this group
  7. In the menu on the left click on All Membersand check the 4th column called Delivery, every team member should have option All Email.
  8. After that I would like to credit Mr. Clement Escoffierand please do follow his guidelines @ Clement Escoffier::Send Github commits to a Google Groupon how to finish it. {Thank you Clement :)}
  9. If the link becomes unavailable here is another link to my gDocs @ PDF version of Clements guide
  1. 首先登录你的谷歌账户
  2. 转到Google Groups并在顶部单击Create Group
  3. 输入群组名称、群组电子邮件地址(将复制/粘贴到 GitHub 服务挂钩->电子邮件地址)、群组描述
  4. 在点击顶部的创建按钮之后,您的新组现在应该被创建
  5. 之后在左侧的菜单中点击邀请成员并输入您团队成员的电子邮件地址
  6. 在点击发送邀请(当您的成员接受邀请时)之后,他们现在正式成为该组的成员
  7. 在左侧菜单中单击所有成员并检查名为Delivery的第 4 列,每个团队成员都应该有选项 All Email
  8. 在那之后,我想感谢 Clement Escoffier 先生,请务必遵循他的指导方针 @ Clement Escoffier::Send Github 向 Google Group 提交关于如何完成它的承诺。{谢谢克莱门特:)}
  9. 如果链接变得不可用,这里是另一个链接到我的 gDocs @ PDF 版本的 Clements 指南

回答by Eric

This is my way of send email notification to users every time some one push to the repository.

这是我每次推送到存储库时向用户发送电子邮件通知的方式。

Setting Up Git Commit Email Notification

设置 Git 提交电子邮件通知

It's based on Andy Parkins's scripts. I change it to used SMTP to send email. Of course, gmail's SMTP can also be used.

它基于安迪·帕金斯的剧本。我将其更改为使用 SMTP 发送电子邮件。当然也可以使用gmail的SMTP。

回答by mavam

Robin Sommer's git-notifiergenerates also very nice summaries in the following format:

Robin Sommergit-notifier也以以下格式生成非常好的摘要:

Subject: [git/git-notifier] master: Adding www target to Makefile. (7dc1f95)

Repository : ssh://<removed>/git-notifier

On branch  : master

>---------------------------------------------------------------

commit 7dc1f95c97275618d5bde1aaf6760cd7ff6a6ef7
Author: Robin Sommer <[email protected]>
Date:   Sun Dec 19 20:21:38 2010 -0800

    Adding www target to Makefile.

>---------------------------------------------------------------

 Makefile |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/Makefile b/Makefile
index e184c66..9c9951b 100644
--- a/Makefile
+++ b/Makefile
@@ -5,6 +5,8 @@ VERSION   = 0.1

 DISTFILES = git-notifier README COPYING

+WWW = $(HOME)/www/git-notifier
+
 all:

 dist:
@@ -13,3 +15,7 @@ dist:
    cp $(DISTFILES) git-notifier-$(VERSION)
    tar czvf git-notifier-$(VERSION).tgz git-notifier-$(VERSION)
    rm -rf git-notifier-$(VERSION)
+
+www: dist
+   rst2html.py README >$(WWW)/index.html
+   cp git-notifier-$(VERSION).tgz $(WWW)

回答by HiQ CJ

setting hooks.showrev is making no distinguishable difference? :-/

设置 hooks.showrev 没有明显区别?:-/

Sample conf:

示例配置:

# less users/cj.git/config 
[core]
        repositoryformatversion = 0
        filemode = true
        bare = true
[hooks]
        mailinglist = [email protected]
        showrev = "git show -C %s; echo"
        emailprefix = "[sabu gitosis server] "

回答by HiQ CJ

I managed to do this, but had to opt for using the contrib script, not the other (perl) script by Alexandre Julliard. It seems fancier and more configurable, but with postfix I had no mail command which would accept "-s"? Here's my way:

我设法做到了这一点,但不得不选择使用 contrib 脚本,而不是 Alexandre Julliard 的其他 (perl) 脚本。它看起来更漂亮,更可配置,但是使用 postfix 我没有接受“-s”的邮件命令?这是我的方法:

http://pastie.textmate.org/695323

http://pastie.textmate.org/695323

It would be nice to show some more info, like the full patch, gitweb link and commit graph as well, but this script can only do the first - if I play around with hooks.showrev it seems.

显示更多信息会很好,比如完整的补丁、gitweb 链接和提交图,但这个脚本只能做第一个 - 如果我玩 hooks.showrev 似乎。

Anyway, cheers and thanks for the suggestions!

无论如何,欢呼并感谢您的建议!

回答by Sytse Sijbrandij

If you use GitLab you can use the 'Email-on-push' project service for this, it can be found under services in project settings.

如果您使用 GitLab,您可以为此使用“Email-on-push”项目服务,它可以在项目设置的服务下找到。

回答by tomaszbak

You can use pre-commit:

您可以使用预提交:

#!/usr/bin/env ruby

require 'mail'

Mail.defaults do
  delivery_method :smtp,
    address: 'smtp.gmail.com',
    port: 587,
    user_name: '...',
    password: '...',
    authentication: 'plain',
    enable_starttls_auto: true
end

changes=`git diff --cached --unified=0 Gemfile Bowerfile`

unless changes.empty?
  Mail.deliver do
    from     '...'
    to       '...'
    subject  '[PROJECT] Plese confirm team can use libraries'
    body     changes
  end
end

Install:

安装:

cd project
cp pre-commit .git/hooks
chmod +x .git/hooks/pre-commit
gem install mail

Test:

测试:

echo "# some change" >> Gemfile && git commit -m 'some change' Gemfile

回答by pocorall

If you use windows, scm-notifierwould be helpful.

如果您使用 Windows,scm-notifier会有所帮助。

回答by Tal Weiss

Not exactly a full answer since it is Github-specific, but if you happen to use Github it is extremely easy to configure "Service Hooks".
For each repository you wish to monitor, enter Settings / Service Hooks.
There are plenty of available integrations, such as Trac, Twitter, Amazon SNS, Jira, Asana, Bugzilla, FogBugz, IRC, Jabber, Pivotal Tracker, Trello and Email....
Simply select email and feed it with a group email address.
We use the email notifications to sync our developers.

不完全是一个完整的答案,因为它是特定于 Github 的,但是如果您碰巧使用 Github,配置“服务挂钩”非常容易。
对于您希望监控的每个存储库,请输入 Settings / Service Hooks。
有很多可用的集成,例如 Trac、Twitter、Amazon SNS、Jira、Asana、Bugzilla、FogBugz、IRC、Jabber、Pivo​​tal Tracker、Trello 和电子邮件......
只需选择电子邮件并使用群组电子邮件地址提供它。
我们使用电子邮件通知来同步我们的开发人员。