Line | |
---|
1 | #!/usr/bin/env perl
|
---|
2 |
|
---|
3 | use warnings;
|
---|
4 | use strict;
|
---|
5 |
|
---|
6 | use lib "/usr/lib/obs/server";
|
---|
7 | #use BSConfiguration;
|
---|
8 | #use BSRPC;
|
---|
9 | use BSNotify;
|
---|
10 | use Data::Dumper;
|
---|
11 |
|
---|
12 | #
|
---|
13 | # run this
|
---|
14 | # as user
|
---|
15 | # obsrun
|
---|
16 | # in directory
|
---|
17 | # /usr/lib/obs/server
|
---|
18 | #
|
---|
19 |
|
---|
20 | sub 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 |
|
---|
44 | notify( '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.