svn diff notification

    A quick trick for receiving notifications of changes in svn
    It was necessary to receive notifications of changes in svn.
    In svn there is the ability to configure various hooks for various actions.
    A simple example of receiving notifications by e-mail (you can use the mail command, but it wasn’t in the conditions of the task, there was also no sendmail, etc. In general, you can do it anything, but this is the easiest option that fits the conditions of the task). Now this script needs to be placed in / home / svn / masterpanel / hooks / post-commit. Give it execute rights for the owner user.

    #!/usr/bin/perl -w
    use Net::SMTP_auth;

    my $repos=$ARGV[0];
    my $rev=$ARGV[1];
    my $change_data=`/usr/local/bin/svnlook diff -r $rev /home/svn/masterpanel/`;

    $smtp = Net::SMTP_auth->new('smtp.example.com');
    $smtp->auth('CRAM-MD5', 'some_login', 'some_pass');

    $smtp->mail('svn@example.ru');
    $smtp->to('masters@example.com');

    $smtp->data();
    $smtp->datasend("Subject: svn.example.com\n");
    $smtp->datasend('From: svn@example.com');
    $smtp->datasend("\n");
    $smtp->datasend("$repos\n");
    $smtp->datasend("$rev\n");
    $smtp->datasend("$change_data\n");
    $smtp->dataend();

    $smtp->quit;




    Also popular now: