mirror of
https://github.com/vishapoberon/compiler.git
synced 2026-04-06 15:42:25 +00:00
Working post push hook now?
This commit is contained in:
parent
b495b2725c
commit
77f6fa772c
1 changed files with 22 additions and 8 deletions
|
|
@ -9,6 +9,14 @@ use POSIX "strftime";
|
||||||
use CGI qw(:standard escapeHTML);
|
use CGI qw(:standard escapeHTML);
|
||||||
use JSON;
|
use JSON;
|
||||||
|
|
||||||
|
sub writelog {
|
||||||
|
my ($msg) = @_;
|
||||||
|
|
||||||
|
open(LOG, ">>/tmp/postpush.log") or die "Could not create postpush.log";
|
||||||
|
flock(LOG, 2) or die "Could not lock postpush.log";
|
||||||
|
print LOG sprintf("%s %s\n", strftime("%Y/%m/%d %H.%M.%S", localtime), $msg);
|
||||||
|
close(LOG);
|
||||||
|
}
|
||||||
|
|
||||||
my $postdata = from_json(param('POSTDATA'));
|
my $postdata = from_json(param('POSTDATA'));
|
||||||
|
|
||||||
|
|
@ -19,16 +27,22 @@ my $name = $postdata->{'head_commit'}->{'author'}->{'name'};
|
||||||
my $branch = $ref; $branch =~ s'^.*\/'';
|
my $branch = $ref; $branch =~ s'^.*\/'';
|
||||||
my $repo = $url; $repo =~ s'^.*\/'';
|
my $repo = $url; $repo =~ s'^.*\/'';
|
||||||
|
|
||||||
|
#my $repo="repo"; my $branch="branch"; my $name="name";
|
||||||
|
|
||||||
|
writelog "Post push github web hook for repository $repo, branch $branch, name $name.";
|
||||||
|
|
||||||
|
my $child = fork;
|
||||||
|
if (not defined $child) {die "Fork failed.";}
|
||||||
|
if ($child) {
|
||||||
|
# parent process
|
||||||
|
writelog "Started ssh, pid = $child.";
|
||||||
|
} else {
|
||||||
|
# child process
|
||||||
|
exec 'ssh root@oberon "perl vishap/voc/src/tools/testcoordinator/buildall.pl >/tmp/buildall.log &"';
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
print header(),
|
print header(),
|
||||||
start_html("Vishap Oberon github post push web hook."),
|
start_html("Vishap Oberon github post push web hook."),
|
||||||
p("Repository $repo, branch $branch, name $name."),
|
p("Repository $repo, branch $branch, name $name."),
|
||||||
end_html();
|
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 strftime("%Y/%m/%d %H.%M.%S", localtime), " Repository $repo, branch $branch, name $name.\n";
|
|
||||||
close(LOG);
|
|
||||||
|
|
||||||
system "ssh root@oberon perl vishap/voc/src/tools/testcoordinator/buildall.pl >/tmp/buildall.log &";
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue