forked from lix-project/hydra
Merge remote-tracking branch 'origin/master' into update-nix
This commit is contained in:
commit
d61702f86d
|
@ -185,7 +185,7 @@ Example configuration:
|
||||||
hydra_admin = admin
|
hydra_admin = admin
|
||||||
# Allow all users in the dev group to restart jobs and cancel builds
|
# Allow all users in the dev group to restart jobs and cancel builds
|
||||||
dev = restart-jobs
|
dev = restart-jobs
|
||||||
dev = cancel-builds
|
dev = cancel-build
|
||||||
</role_mapping>
|
</role_mapping>
|
||||||
</ldap>
|
</ldap>
|
||||||
```
|
```
|
||||||
|
|
|
@ -172,17 +172,6 @@ Sets Gitlab CI status.
|
||||||
|
|
||||||
- `gitlab_authorization.<projectId>`
|
- `gitlab_authorization.<projectId>`
|
||||||
|
|
||||||
## HipChat notification
|
|
||||||
|
|
||||||
Sends hipchat chat notifications when a build finish.
|
|
||||||
|
|
||||||
### Configuration options
|
|
||||||
|
|
||||||
- `hipchat.[].jobs`
|
|
||||||
- `hipchat.[].builds`
|
|
||||||
- `hipchat.[].token`
|
|
||||||
- `hipchat.[].notify`
|
|
||||||
|
|
||||||
## InfluxDB notification
|
## InfluxDB notification
|
||||||
|
|
||||||
Writes InfluxDB events when a builds finished.
|
Writes InfluxDB events when a builds finished.
|
||||||
|
|
|
@ -91,6 +91,7 @@
|
||||||
DigestSHA1
|
DigestSHA1
|
||||||
EmailMIME
|
EmailMIME
|
||||||
EmailSender
|
EmailSender
|
||||||
|
FileLibMagic
|
||||||
FileSlurper
|
FileSlurper
|
||||||
FileWhich
|
FileWhich
|
||||||
final.nix.perl-bindings
|
final.nix.perl-bindings
|
||||||
|
|
|
@ -228,8 +228,12 @@ in
|
||||||
useDefaultShell = true;
|
useDefaultShell = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
nix.trustedUsers = [ "hydra-queue-runner" ];
|
nix.settings = {
|
||||||
|
trusted-users = [ "hydra-queue-runner" ];
|
||||||
|
gc-keep-outputs = true;
|
||||||
|
gc-keep-derivations = true;
|
||||||
|
};
|
||||||
|
|
||||||
services.hydra-dev.extraConfig =
|
services.hydra-dev.extraConfig =
|
||||||
''
|
''
|
||||||
using_frontend_proxy = 1
|
using_frontend_proxy = 1
|
||||||
|
@ -256,11 +260,6 @@ in
|
||||||
|
|
||||||
environment.variables = hydraEnv;
|
environment.variables = hydraEnv;
|
||||||
|
|
||||||
nix.extraOptions = ''
|
|
||||||
gc-keep-outputs = true
|
|
||||||
gc-keep-derivations = true
|
|
||||||
'';
|
|
||||||
|
|
||||||
systemd.services.hydra-init =
|
systemd.services.hydra-init =
|
||||||
{ wantedBy = [ "multi-user.target" ];
|
{ wantedBy = [ "multi-user.target" ];
|
||||||
requires = optional haveLocalDB "postgresql.service";
|
requires = optional haveLocalDB "postgresql.service";
|
||||||
|
|
|
@ -7,15 +7,16 @@ use base 'Hydra::Base::Controller::NixChannel';
|
||||||
use Hydra::Helper::Nix;
|
use Hydra::Helper::Nix;
|
||||||
use Hydra::Helper::CatalystUtils;
|
use Hydra::Helper::CatalystUtils;
|
||||||
use File::Basename;
|
use File::Basename;
|
||||||
|
use File::LibMagic;
|
||||||
use File::stat;
|
use File::stat;
|
||||||
use Data::Dump qw(dump);
|
use Data::Dump qw(dump);
|
||||||
use Nix::Store;
|
use Nix::Store;
|
||||||
use Nix::Config;
|
use Nix::Config;
|
||||||
use List::SomeUtils qw(all);
|
use List::SomeUtils qw(all);
|
||||||
use Encode;
|
use Encode;
|
||||||
use MIME::Types;
|
|
||||||
use JSON::PP;
|
use JSON::PP;
|
||||||
|
|
||||||
|
use feature 'state';
|
||||||
|
|
||||||
sub buildChain :Chained('/') :PathPart('build') :CaptureArgs(1) {
|
sub buildChain :Chained('/') :PathPart('build') :CaptureArgs(1) {
|
||||||
my ($self, $c, $id) = @_;
|
my ($self, $c, $id) = @_;
|
||||||
|
@ -236,14 +237,10 @@ sub serveFile {
|
||||||
$c->stash->{'plain'} = { data => grab(cmd => ["nix", "--experimental-features", "nix-command",
|
$c->stash->{'plain'} = { data => grab(cmd => ["nix", "--experimental-features", "nix-command",
|
||||||
"store", "cat", "--store", getStoreUri(), "$path"]) };
|
"store", "cat", "--store", getStoreUri(), "$path"]) };
|
||||||
|
|
||||||
# Detect MIME type. Borrowed from Catalyst::Plugin::Static::Simple.
|
# Detect MIME type.
|
||||||
my $type = "text/plain";
|
state $magic = File::LibMagic->new(follow_symlinks => 1);
|
||||||
if ($path =~ /.*\.(\S{1,})$/xms) {
|
my $info = $magic->info_from_filename($path);
|
||||||
my $ext = $1;
|
my $type = $info->{mime_with_encoding};
|
||||||
my $mimeTypes = MIME::Types->new(only_complete => 1);
|
|
||||||
my $t = $mimeTypes->mimeTypeOf($ext);
|
|
||||||
$type = ref $t ? $t->type : $t if $t;
|
|
||||||
}
|
|
||||||
$c->response->content_type($type);
|
$c->response->content_type($type);
|
||||||
$c->forward('Hydra::View::Plain');
|
$c->forward('Hydra::View::Plain');
|
||||||
}
|
}
|
||||||
|
@ -288,29 +285,7 @@ sub download : Chained('buildChain') PathPart {
|
||||||
my $path = $product->path;
|
my $path = $product->path;
|
||||||
$path .= "/" . join("/", @path) if scalar @path > 0;
|
$path .= "/" . join("/", @path) if scalar @path > 0;
|
||||||
|
|
||||||
if (isLocalStore) {
|
serveFile($c, $path);
|
||||||
|
|
||||||
notFound($c, "File '" . $product->path . "' does not exist.") unless -e $product->path;
|
|
||||||
|
|
||||||
# Make sure the file is in the Nix store.
|
|
||||||
$path = checkPath($self, $c, $path);
|
|
||||||
|
|
||||||
# If this is a directory but no "/" is attached, then redirect.
|
|
||||||
if (-d $path && substr($c->request->uri, -1) ne "/") {
|
|
||||||
return $c->res->redirect($c->request->uri . "/");
|
|
||||||
}
|
|
||||||
|
|
||||||
$path = "$path/index.html" if -d $path && -e "$path/index.html";
|
|
||||||
|
|
||||||
notFound($c, "File '$path' does not exist.") if !-e $path;
|
|
||||||
|
|
||||||
notFound($c, "Path '$path' is a directory.") if -d $path;
|
|
||||||
|
|
||||||
$c->serve_static_file($path);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
serveFile($c, $path);
|
|
||||||
}
|
|
||||||
|
|
||||||
$c->response->headers->last_modified($c->stash->{build}->stoptime);
|
$c->response->headers->last_modified($c->stash->{build}->stoptime);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,89 +0,0 @@
|
||||||
package Hydra::Plugin::HipChatNotification;
|
|
||||||
|
|
||||||
use strict;
|
|
||||||
use warnings;
|
|
||||||
use parent 'Hydra::Plugin';
|
|
||||||
use LWP::UserAgent;
|
|
||||||
use Hydra::Helper::CatalystUtils;
|
|
||||||
|
|
||||||
sub isEnabled {
|
|
||||||
my ($self) = @_;
|
|
||||||
return defined $self->{config}->{hipchat};
|
|
||||||
}
|
|
||||||
|
|
||||||
sub buildFinished {
|
|
||||||
my ($self, $topbuild, $dependents) = @_;
|
|
||||||
|
|
||||||
my $cfg = $self->{config}->{hipchat};
|
|
||||||
my @config = defined $cfg ? ref $cfg eq "ARRAY" ? @$cfg : ($cfg) : ();
|
|
||||||
|
|
||||||
my $baseurl = $self->{config}->{'base_uri'} || "http://localhost:3000";
|
|
||||||
|
|
||||||
# Figure out to which rooms to send notification. For each email
|
|
||||||
# room, we send one aggregate message.
|
|
||||||
my %rooms;
|
|
||||||
foreach my $build ($topbuild, @{$dependents}) {
|
|
||||||
my $prevBuild = getPreviousBuild($build);
|
|
||||||
my $jobName = showJobName $build;
|
|
||||||
|
|
||||||
foreach my $room (@config) {
|
|
||||||
my $force = $room->{force};
|
|
||||||
next unless $jobName =~ /^$room->{jobs}$/;
|
|
||||||
|
|
||||||
# If build is cancelled or aborted, do not send email.
|
|
||||||
next if ! $force && ($build->buildstatus == 4 || $build->buildstatus == 3);
|
|
||||||
|
|
||||||
# If there is a previous (that is not cancelled or aborted) build
|
|
||||||
# with same buildstatus, do not send email.
|
|
||||||
next if ! $force && defined $prevBuild && ($build->buildstatus == $prevBuild->buildstatus);
|
|
||||||
|
|
||||||
$rooms{$room->{room}} //= { room => $room, builds => [] };
|
|
||||||
push @{$rooms{$room->{room}}->{builds}}, $build;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return if scalar keys %rooms == 0;
|
|
||||||
|
|
||||||
my ($authors, $nrCommits) = getResponsibleAuthors($topbuild, $self->{plugins});
|
|
||||||
|
|
||||||
# Send a message to each room.
|
|
||||||
foreach my $roomId (keys %rooms) {
|
|
||||||
my $room = $rooms{$roomId};
|
|
||||||
my @deps = grep { $_->id != $topbuild->id } @{$room->{builds}};
|
|
||||||
|
|
||||||
my $img =
|
|
||||||
$topbuild->buildstatus == 0 ? "$baseurl/static/images/checkmark_16.png" :
|
|
||||||
$topbuild->buildstatus == 2 ? "$baseurl/static/images/dependency_16.png" :
|
|
||||||
$topbuild->buildstatus == 4 ? "$baseurl/static/images/cancelled_16.png" :
|
|
||||||
"$baseurl/static/images/error_16.png";
|
|
||||||
|
|
||||||
my $msg = "";
|
|
||||||
$msg .= "<img src='$img'/> ";
|
|
||||||
$msg .= "Job <a href='$baseurl/job/${\$topbuild->jobset->get_column('project')}/${\$topbuild->jobset->get_column('name')}/${\$topbuild->get_column('job')}'>${\showJobName($topbuild)}</a>";
|
|
||||||
$msg .= " (and ${\scalar @deps} others)" if scalar @deps > 0;
|
|
||||||
$msg .= ": <a href='$baseurl/build/${\$topbuild->id}'>" . showStatus($topbuild) . "</a>";
|
|
||||||
|
|
||||||
if (scalar keys %{$authors} > 0) {
|
|
||||||
# FIXME: HTML escaping
|
|
||||||
my @x = map { "<a href='mailto:$authors->{$_}'>$_</a>" } (sort keys %{$authors});
|
|
||||||
$msg .= ", likely due to ";
|
|
||||||
$msg .= "$nrCommits commits by " if $nrCommits > 1;
|
|
||||||
$msg .= join(" or ", scalar @x > 1 ? join(", ", @x[0..scalar @x - 2]) : (), $x[-1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
print STDERR "sending hipchat notification to room $roomId: $msg\n";
|
|
||||||
|
|
||||||
my $ua = LWP::UserAgent->new();
|
|
||||||
my $resp = $ua->post('https://api.hipchat.com/v1/rooms/message?format=json&auth_token=' . $room->{room}->{token}, {
|
|
||||||
room_id => $roomId,
|
|
||||||
from => 'Hydra',
|
|
||||||
message => $msg,
|
|
||||||
message_format => 'html',
|
|
||||||
notify => $room->{room}->{notify} || 0,
|
|
||||||
color => $topbuild->buildstatus == 0 ? 'green' : 'red' });
|
|
||||||
|
|
||||||
print STDERR $resp->status_line, ": ", $resp->decoded_content,"\n" if !$resp->is_success;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
1;
|
|
|
@ -1,5 +1,5 @@
|
||||||
div.skip-topbar {
|
div.skip-topbar {
|
||||||
padding-top: 40px;
|
padding-top: 20px;
|
||||||
margin-bottom: 1.5em;
|
margin-bottom: 1.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,6 +146,26 @@ td.step-status span.warn {
|
||||||
padding-top: 1.5rem;
|
padding-top: 1.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.container {
|
||||||
|
max-width: 80%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tab-content {
|
||||||
|
margin-right: 0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar-nav {
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropdown-item {
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) {
|
@media (prefers-color-scheme: dark) {
|
||||||
/* Prevent some flickering */
|
/* Prevent some flickering */
|
||||||
html {
|
html {
|
||||||
|
|
Loading…
Reference in a new issue