gogs icon indicating copy to clipboard operation
gogs copied to clipboard

Email notifications for pushes

Open liko28s opened this issue 10 years ago • 24 comments

Hi guys, I assume it is not a mistake, but with notifications enabled, no notifications are sended when a push has been realized.

actually the notification only send in registration related events, and collaboration, but it would be an excellent feature notify pushes and commits.

Thanks

liko28s avatar Aug 05 '15 15:08 liko28s

Thanks your feedback!

It's more like a feature request in the repository settings about receiving these type of e-mails.

unknwon avatar Aug 06 '15 01:08 unknwon

Currently what can I do to test wether my email setting is correct? I tried adding an issue, or comment on an issue, or add a secondary email address, but none of these triggered notification email.

JokerQyou avatar Sep 12 '15 06:09 JokerQyou

@JokerQyou no e-mail for creating issues on your own repository.

Please follow on https://github.com/gogits/gogs/issues/1531 for your purpose.

unknwon avatar Sep 12 '15 11:09 unknwon

@liko28s you can easily use git hook, such as: multimail

biji avatar Dec 27 '15 11:12 biji

:+1: +1

McLive avatar Feb 13 '16 18:02 McLive

@Unknwon Any plans when this will be added? I'm really looking forward to this feature. :)

McLive avatar Mar 09 '16 18:03 McLive

@McLive you can use a post-receive git hook for now...

unknwon avatar Mar 09 '16 18:03 unknwon

@Unknwon Ok but not to have to do this for every repository would be nice. :smile:

McLive avatar Mar 13 '16 19:03 McLive

@McLive Not everybody needs this as well.

unknwon avatar Mar 13 '16 19:03 unknwon

@Unknwon We also need this. :/

shenziro avatar Aug 23 '16 15:08 shenziro

you can edit /usr/share/git-core/templates/hooks/post-receive to set default for all new project, so it contains: /home/git/git_multimail.py

(may be this can be put on wiki :)

biji avatar Aug 24 '16 06:08 biji

We would also be very happy having an easy option to enable mails on commits

meisterlampe avatar Mar 07 '17 16:03 meisterlampe

Hey, I've got a quite strange problem with using the post-receive hook for sending a mail to our mailing list. We initially simply added the following content to the file /path/to/repo/hooks/post-receive to achieve a mail being sent:

. /usr/share/doc/git/contrib/hooks/post-receive-email

After an update some while ago, the content was automatically replaced by this:

#!/usr/bin/env bash
"/opt/gogs/gogs" hook --config='/etc/gogs/conf/app.ini' post-receive

But now, after adding the line . /usr/share/doc/git/contrib/hooks/post-receive-email again, Gogs acts a little strange: Either the pushes won't show up in the dashboard (when placed before the "/opt/gogs/gogs" hook [...] line) or the mail won't be sent (when placed after the "/opt/gogs/gogs" hook [...] line).

Can someone help?

OS:     Debian 8.7
Kernel: 4.4.6-fai-amd64
Gogs:   0.10.18-1490585395.f40eb97.jessie amd64 (installed from packager.io)

wntrstn avatar Mar 27 '17 09:03 wntrstn

@DavidCraven: I can explain this behavior: post-receive hooks take on stdin the list of refs that have been changed. So the first command will receive and consume the input (depending on the order of post-receive-email and /opt/gogs/gogs in your hook) and the second will see an empty stdin as if no change had happened. IOW you need to duplicate stdin and pass it separately to each one of the two commands.

I assume that this problem disappears if you set your email hook from within Gogs (by enabling Git hooks and configuring them from there), tho I haven't tested it yet.

monnier avatar Apr 07 '17 19:04 monnier

I just removed the line from /path/to/repo/hooks/post-receive and added it to https://mygogs.de/user/repo/settings/hooks/git/post-receive. Tested it - pushes show up in the dashboard, but no mail was sent. Is there any easy way of splitting stdin? I'm really not sure, is it passed as $@ or so?

wntrstn avatar Apr 07 '17 20:04 wntrstn

@DavidCraven https://git-scm.com/docs/githooks#pre-receive

#!/bin/sh

while read oldrev newrev refname
do
    echo "post-receive" $oldrev $newrev $refname
done

unknwon avatar Apr 07 '17 20:04 unknwon

Thanks, I will try this asap and come back with results!

wntrstn avatar Apr 07 '17 21:04 wntrstn

Ok, I got it solved pretty easy by using pee from the moreutils package, which duplicates stdin to all scripts.

I created the folder /path/to/repo/hooks/post-receive.d and created an own script in there for both the gogs function and the mailing list announcement like this:

$ ls -l /path/to/repo/hooks/post-receive.d/*
/path/to/repo/hooks/post-receive.d/gogs
/path/to/repo/hooks/post-receive.d/mail
$ cat /path/to/repo/hooks/post-receive.d/gogs
#!/usr/bin/env bash
"/opt/gogs/gogs" hook --config='/etc/gogs/conf/app.ini' post-receive
$ cat /path/to/repo/hooks/post-receive.d/mail
. /usr/share/doc/git/contrib/hooks/post-receive-email

Then I put this in /path/to/repo/hooks/post-receive:

#!/bin/bash
HOOKDIR="$(dirname $0)/$(basename $0).d"
if [ -d "$HOOKDIR" ]; then
  pee $HOOKDIR/* $*
fi

Now both scripts are run correctly and I get both the notification in gogs and the mail to our mailing list. Got the idea from here.

wntrstn avatar Apr 10 '17 09:04 wntrstn

This is a must-have feature. I certainly need it, at least :)

There is no way for a post-receive hook to find who performed the push, so the resulting email necessarily lacks valuable info this way. That, plus configuration accross repositories being a pain…

rems4e avatar Jul 03 '17 15:07 rems4e

Hi, is pre-recieve hook still the only way to get email notifications for pushes?

lassana avatar Jan 05 '19 01:01 lassana

I also think it is killer feature. For me it is not absolutely necessary to include the diffs directly in the email, but just links to the commits on the gogs web.

mclei-asw avatar Sep 05 '19 11:09 mclei-asw

Blocked by #2109.

unknwon avatar May 11 '20 04:05 unknwon

Wondering how to get email notifications for pushes and commits, containing author's details and code diffs?

They should be sent to all members having access to repository.

ivptr avatar Sep 30 '21 11:09 ivptr

Back in 2016, I implemented this for my fork of the Gogs code at the time. Look at stroucki/gogs, branch commitemails. It mails all watchers of the relevant repository. I believe my code was adopted into gitea shortly thereafter.

Gogs has served well since then. I am looking at what it will take to update, and it seems I will have to implement this again...

stroucki avatar Sep 03 '22 04:09 stroucki