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WSUD57B26PCRAHMZIQ5SIWJIK7A74ENKEQLAC
OOQ2D3KCLFPYNAN253PHWLBQMB6OMO2KYQWQXLTP65SQAYZWQ5LAC
BLVQGJ4LITFCIR3KAUX3GWAHMYH3XXFC4BDXUSXUVEJFEJ7IMM4AC
JAH3UPWAVSHXIPNGL6PROQPZBYZHPJNFONWBDZX4HCX646USZXUQC
5EQYVRWECBDJORGI5DRIOUEJXSXMRCQNT2562BM4Z4U52LT7JUHAC
{
auto notificationSenderQueue_(notificationSenderQueue.lock());
notificationSenderQueue_->push(NotificationItem{NotificationItem::Type::Started, build->id});
}
notificationSenderWakeup.notify_one();
enqueueNotificationItem({NotificationItem::Type::BuildStarted, build->id});
for (auto id : buildIDs) {
{
auto notificationSenderQueue_(notificationSenderQueue.lock());
notificationSenderQueue_->push(NotificationItem{NotificationItem::Type::Finished, id});
}
notificationSenderWakeup.notify_one();
}
for (auto id : buildIDs)
enqueueNotificationItem({NotificationItem::Type::BuildFinished, id});
if (unlink(logPath.c_str()) != 0)
throw SysError(format("unlinking ‘%1%’") % logPath);
if (unlink(item.logPath.c_str()) != 0)
throw SysError(format("unlinking ‘%1%’") % item.logPath);
/* Run plugins. We do this after log compression to ensure
that the log file doesn't change while the plugins may
be accessing it. */
enqueueNotificationItem({NotificationItem::Type::StepFinished, item.id, {}, item.stepNr, dstPath});
Strings argv({"hydra-notify", item.type == NotificationItem::Type::Started ? "build-started" : "build-finished", std::to_string(item.id)});
for (auto id : item.dependentIds)
argv.push_back(std::to_string(id));
Strings argv;
switch (item.type) {
case NotificationItem::Type::BuildStarted:
argv = {"hydra-notify", "build-started", std::to_string(item.id)};
for (auto id : item.dependentIds)
argv.push_back(std::to_string(id));
break;
case NotificationItem::Type::BuildFinished:
argv = {"hydra-notify", "build-finished", std::to_string(item.id)};
for (auto id : item.dependentIds)
argv.push_back(std::to_string(id));
break;
case NotificationItem::Type::StepFinished:
argv = {"hydra-notify", "step-finished", std::to_string(item.id), std::to_string(item.stepNr), item.logPath};
break;
};
package Hydra::Helper::PluginHooks;
use strict;
use Exporter;
our @ISA = qw(Exporter);
our @EXPORT = qw(
notifyBuildStarted
notifyBuildFinished);
sub notifyBuildStarted {
my ($plugins, $build) = @_;
foreach my $plugin (@{$plugins}) {
eval {
$plugin->buildStarted($build);
};
if ($@) {
print STDERR "$plugin->buildStarted: $@\n";
}
}
}
sub notifyBuildFinished {
my ($plugins, $build, $dependents) = @_;
foreach my $plugin (@{$plugins}) {
eval {
$plugin->buildFinished($build, $dependents);
};
if ($@) {
print STDERR "$plugin->buildFinished: $@\n";
}
}
}
1;
notifyBuildFinished(\@plugins, $build, [@dependents]);
} elsif ($cmd eq "build-started") {
notifyBuildStarted(\@plugins, $build);
foreach my $plugin (@plugins) {
eval { $plugin->buildFinished($build, [@dependents]); };
if ($@) {
print STDERR "$plugin->buildFinished: $@\n";
}
}
}
elsif ($cmd eq "build-started") {
foreach my $plugin (@plugins) {
eval { $plugin->buildStarted($build); };
if ($@) {
print STDERR "$plugin->buildStarted: $@\n";
}
}
}
elsif ($cmd eq "step-finished") {
my $stepNr = shift @ARGV or die;
my $step = $build->buildsteps->find({stepnr => $stepNr})
or die "step $stepNr does not exist\n";
my $logPath = shift @ARGV or die;
foreach my $plugin (@plugins) {
eval { $plugin->stepFinished($step, $logPath); };
if ($@) {
print STDERR "$plugin->stepFinished: $@\n";
}
}