Email notifications for pushes
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
Thanks your feedback!
It's more like a feature request in the repository settings about receiving these type of e-mails.
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 no e-mail for creating issues on your own repository.
Please follow on https://github.com/gogits/gogs/issues/1531 for your purpose.
@liko28s you can easily use git hook, such as: multimail
:+1: +1
@Unknwon Any plans when this will be added? I'm really looking forward to this feature. :)
@McLive you can use a post-receive git hook for now...
@Unknwon Ok but not to have to do this for every repository would be nice. :smile:
@McLive Not everybody needs this as well.
@Unknwon We also need this. :/
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 :)
We would also be very happy having an easy option to enable mails on commits
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)
@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.
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?
@DavidCraven https://git-scm.com/docs/githooks#pre-receive
#!/bin/sh
while read oldrev newrev refname
do
echo "post-receive" $oldrev $newrev $refname
done
Thanks, I will try this asap and come back with results!
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.
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…
Hi, is pre-recieve hook still the only way to get email notifications for pushes?
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.
Blocked by #2109.
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.
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...