Git push webhook script beginning to work. Fiddle with readme.

This commit is contained in:
David Brown 2016-06-26 17:07:40 +01:00
parent d8e26c635e
commit a5a8809b91
4 changed files with 46 additions and 63 deletions

View file

@ -0,0 +1,31 @@
#!/usr/bin/perl -w
use strict;
use warnings;
use CGI qw(:standard escapeHTML);
use JSON;
my $postdata = from_json(param('POSTDATA'));
my $url = $postdata->{'repository'}->{'url'};
my $ref = $postdata->{'ref'};
my $name = $postdata->{'head_commit'}->{'author'}->{'name'};
my $branch = $ref; $branch =~ s'^.*\/'';
my $repo = $url; $repo =~ s'^.*\/'';
print header(),
start_html("Vishap Oberon github post push web hook."),
p("Repository $repo, branch $branch, name $name."),
end_html();
open(LOG, ">>/tmp/postpush.log") or die "Could not create postpush.log";
flock(LOG, 2) or die "Could not lock postpush.log";
printf LOG "Repository $repo, branch $branch, name $name.";
close(LOG);