source: obs_notify_generic/obs_send_notification.pl@ 1185

Last change on this file since 1185 was 1183, checked in by joergs, on Jun 12, 2015 at 3:35:58 PM

tests

  • Property svn:executable set to *
File size: 1.2 KB
Line 
1#!/usr/bin/env perl
2
3use warnings;
4use strict;
5
6use lib "/usr/lib/obs/server";
7#use BSConfiguration;
8#use BSRPC;
9use BSNotify;
10use Data::Dumper;
11
12sub notify {
13 my ($type, $p) = @_;
14 # strip
15 $p = { map {$_ => $p->{$_}} grep {defined($p->{$_}) && !ref($p->{$_})} sort keys %{$p || {}} };
16 if (1) {
17 BSNotify::notify_plugins($type, $p);
18 } else {
19 # always route over to the src server
20 print "srcserver: ", $BSConfig::srcserver, "\n";
21 my $param = {
22 'uri' => "$BSConfig::srcserver/notify/$type",
23 'request' => 'POST',
24 'headers' => [ 'Content-Type: application/x-www-form-urlencoded' ],
25 'timeout' => 60,
26 };
27 my @args = map {"$_=$p->{$_}"} sort keys %$p;
28 print Dumper( @args );
29 eval {
30 BSRPC::rpc($param, undef, @args);
31 };
32 warn($@) if $@;
33 }
34}
35
36#notify( 'MY_TYPE', { project => 'myprj' , 'repo' => 'myrepo' } );
37#notify( 'REPO_PUBLISHED', { 'project' => 'internal:master' , 'repository' => 'win_cross' } );
38#notify( 'BUILD_SUCCESS', { 'project' => 'bareos:master', 'package' => 'bareos-docs', 'repository' => 'Debian_8.0', 'arch' => 'x86_64' } );
39notify( 'BUILD_SUCCESS', { 'project' => 'internal:master', 'package' => 'winbareos-opsi', 'repository' => 'win_cross', 'arch' => 'x86_64' } );
Note: See TracBrowser for help on using the repository browser.