source: obs_notify_generic/obs_send_notification.pl@ 1246

Last change on this file since 1246 was 1187, checked in by joergs, on Jun 17, 2015 at 6:02:17 PM

test

  • Property svn:executable set to *
File size: 1.4 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
12#
13# run this
14# as user
15# obsrun
16# in directory
17# /usr/lib/obs/server
18#
19
20sub notify {
21 my ($type, $p) = @_;
22 # strip
23 $p = { map {$_ => $p->{$_}} grep {defined($p->{$_}) && !ref($p->{$_})} sort keys %{$p || {}} };
24 if (1) {
25 BSNotify::notify_plugins($type, $p);
26 } else {
27 # always route over to the src server
28 print "srcserver: ", $BSConfig::srcserver, "\n";
29 my $param = {
30 'uri' => "$BSConfig::srcserver/notify/$type",
31 'request' => 'POST',
32 'headers' => [ 'Content-Type: application/x-www-form-urlencoded' ],
33 'timeout' => 60,
34 };
35 my @args = map {"$_=$p->{$_}"} sort keys %$p;
36 print Dumper( @args );
37 eval {
38 BSRPC::rpc($param, undef, @args);
39 };
40 warn($@) if $@;
41 }
42}
43
44notify( 'TEST_TYPE', { project => 'myprj' , 'repo' => 'myrepo' } );
45#notify( 'REPO_PUBLISHED', { 'project' => 'internal:master' , 'repository' => 'win_cross' } );
46#notify( 'BUILD_SUCCESS', { 'project' => 'bareos:master', 'package' => 'bareos-docs', 'repository' => 'Debian_8.0', 'arch' => 'x86_64' } );
47#notify( 'BUILD_SUCCESS', { 'project' => 'internal:master', 'package' => 'winbareos-opsi', 'repository' => 'win_cross', 'arch' => 'x86_64' } );
48#notify( 'BUILD_SUCCESS', { project => 'myprj' , 'repo' => 'myrepo' } );
Note: See TracBrowser for help on using the repository browser.