Git hook to send email notification on repo changes

前端 未结 11 1873
情深已故
情深已故 2020-11-28 01:33

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

相关标签:
11条回答
  • 2020-11-28 02:24

    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.

    0 讨论(0)
  • 2020-11-28 02:25

    Here is the simplest solution I've found:

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

    2) In the main tab click on Settings

    3) From the main navigation choose Service Hooks

    4) From Available Hooks choose Email

    5) Fill in your email address in field Address

    6) Check the checkbox Send from Author

    7) Check the checkbox Active

    8) Click on Update Settings

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

    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 final I 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 }.

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

    1. First login to your google account
    2. Go to Google Groups and 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 members and 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 Members and check the 4th column called Delivery, every team member should have option All Email.
    8. After that I would like to credit Mr. Clement Escoffier and please do follow his guidelines @ Clement Escoffier::Send Github commits to a Google Group on 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
    0 讨论(0)
  • 2020-11-28 02:26

    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
    
    0 讨论(0)
  • 2020-11-28 02:31

    If you use windows, scm-notifier would be helpful.

    0 讨论(0)
  • 2020-11-28 02:33

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

    Setting Up Git Commit Email Notification

    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.

    0 讨论(0)
提交回复
热议问题