Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Email Notifications for pushes #1441

Open
liko28s opened this issue Aug 5, 2015 · 21 comments
Labels
Milestone

Comments

@liko28s
Copy link

@liko28s liko28s commented Aug 5, 2015

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

@unknwon unknwon added the kind/feature label Aug 6, 2015
@unknwon unknwon changed the title Email Notifications Email Notifications for pushes Aug 6, 2015
@unknwon

This comment has been minimized.

Copy link
Member

@unknwon unknwon commented Aug 6, 2015

Thanks your feedback!

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

@unknwon unknwon added this to the 0.7.0 milestone Aug 6, 2015
@unknwon unknwon modified the milestones: 0.8.0, 0.7.0 Sep 3, 2015
@JokerQyou

This comment has been minimized.

Copy link

@JokerQyou JokerQyou commented Sep 12, 2015

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.

@unknwon

This comment has been minimized.

Copy link
Member

@unknwon unknwon commented Sep 12, 2015

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

Please follow on #1531 for your purpose.

@biji

This comment has been minimized.

Copy link

@biji biji commented Dec 27, 2015

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

@unknwon unknwon removed this from the 0.10.0 milestone Feb 7, 2016
@McLive

This comment has been minimized.

Copy link

@McLive McLive commented Feb 13, 2016

👍 +1

@McLive

This comment has been minimized.

Copy link

@McLive McLive commented Mar 9, 2016

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

@unknwon

This comment has been minimized.

Copy link
Member

@unknwon unknwon commented Mar 9, 2016

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

@McLive

This comment has been minimized.

Copy link

@McLive McLive commented Mar 13, 2016

@unknwon Ok but not to have to do this for every repository would be nice. 😄

@unknwon

This comment has been minimized.

Copy link
Member

@unknwon unknwon commented Mar 13, 2016

@McLive Not everybody needs this as well.

@shenziro

This comment has been minimized.

Copy link

@shenziro shenziro commented Aug 23, 2016

@unknwon We also need this. :/

@biji

This comment has been minimized.

Copy link

@biji biji commented Aug 24, 2016

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 :)

@meisterlampe

This comment has been minimized.

Copy link

@meisterlampe meisterlampe commented Mar 7, 2017

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

@davidwinterstein

This comment has been minimized.

Copy link

@davidwinterstein davidwinterstein commented Mar 27, 2017

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)
@monnier

This comment has been minimized.

Copy link

@monnier monnier commented Apr 7, 2017

@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.

@davidwinterstein

This comment has been minimized.

Copy link

@davidwinterstein davidwinterstein commented Apr 7, 2017

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?

@unknwon

This comment has been minimized.

Copy link
Member

@unknwon unknwon commented Apr 7, 2017

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

#!/bin/sh

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

This comment has been minimized.

Copy link

@davidwinterstein davidwinterstein commented Apr 7, 2017

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

@davidwinterstein

This comment has been minimized.

Copy link

@davidwinterstein davidwinterstein commented Apr 10, 2017

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.

@rems4e

This comment has been minimized.

Copy link

@rems4e rems4e commented Jul 3, 2017

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…

@unknwon unknwon added this to the 0.13 milestone Jul 14, 2017
@McLive McLive mentioned this issue Feb 22, 2018
5 of 10 tasks complete
@lassana

This comment has been minimized.

Copy link

@lassana lassana commented Jan 5, 2019

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

@mclei-asw

This comment has been minimized.

Copy link

@mclei-asw mclei-asw commented Sep 5, 2019

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.

@unknwon unknwon modified the milestones: 0.13, 0.12 Oct 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.