2021-08-19 20:36:43 +00:00
|
|
|
use strict;
|
|
|
|
use warnings;
|
Added the InfluxDBNotification plugin including a NixOS test
This adds a `InfluxDBNotification` plugin which is configured as:
```
<influxdb>
url = http://127.0.0.1:8086
db = hydra
</influxdb>
```
which will write a notification for every finished job to the
configured database in InfluxDB looking like:
```
hydra_build_status,cached=false,job=job,jobset=default,project=sample,repo=default,result=success,status=success,system=x86_64-linux build_id="1",build_status=0i,closure_size=584i,duration=0i,main_build_id="1",queued=0i,size=168i 1564156212
```
2019-07-25 07:43:40 +00:00
|
|
|
use LWP::UserAgent;
|
|
|
|
use JSON;
|
|
|
|
|
|
|
|
my $ua = LWP::UserAgent->new;
|
|
|
|
$ua->cookie_jar({});
|
|
|
|
|
|
|
|
sub request_json {
|
|
|
|
my ($opts) = @_;
|
|
|
|
my $req = HTTP::Request->new;
|
|
|
|
$req->method($opts->{method} or "GET");
|
|
|
|
$req->uri("http://localhost:3000$opts->{uri}");
|
|
|
|
$req->header(Accept => "application/json");
|
|
|
|
$req->header(Referer => "http://localhost:3000/") if $opts->{method} eq "POST";
|
|
|
|
$req->content(encode_json($opts->{data})) if defined $opts->{data};
|
|
|
|
my $res = $ua->request($req);
|
|
|
|
print $res->as_string();
|
|
|
|
return $res;
|
|
|
|
}
|
|
|
|
|
|
|
|
my $result = request_json({
|
|
|
|
uri => "/login",
|
|
|
|
method => "POST",
|
|
|
|
data => {
|
|
|
|
username => "root",
|
|
|
|
password => "foobar"
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$result = request_json({
|
|
|
|
uri => '/project/sample',
|
|
|
|
method => 'PUT',
|
|
|
|
data => {
|
|
|
|
displayname => "Sample",
|
|
|
|
enabled => "1",
|
|
|
|
visible => "1",
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$result = request_json({
|
|
|
|
uri => '/jobset/sample/default',
|
|
|
|
method => 'PUT',
|
|
|
|
data => {
|
|
|
|
nixexprpath => "default.nix",
|
|
|
|
nixexprinput => "my-src",
|
|
|
|
inputs => {
|
|
|
|
"my-src" => {
|
|
|
|
type => "path",
|
|
|
|
value => "/run/jobset"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
enabled => "1",
|
|
|
|
visible => "1",
|
|
|
|
checkinterval => "5",
|
|
|
|
keepnr => 1
|
|
|
|
}
|
|
|
|
});
|