Provide a plugin hook for when build steps finish
[?]
May 27, 2016, 12:32 PM
NTEDD7T4M7XXYCWNZN57EJOEH3KI3UYMHOANV4MY2LSUPWX3JRDQCDependencies
- [2]
A2Z3ZJ66Revert "Don't call buildFinished after we already know it failed" - [3]
7LWB2J2ZPeriodically clear orphaned build steps - [4]
NSRWW6LCAdd a plugin to interact with the github status API. - [5]
PLOZBRTRAdd command ‘hydra-queue-runner --status’ to show current status - [6]
X6FOUYFJint2String -> std::to_string - [7]
UNVMKJV5Unify build and step status codes - [8]
FCTX433OAdd buildStarted plugin hook - [9]
BG6PEOB2Make the output size limit configurable - [10]
D5QIOJGP* Move everything up one directory. - [11]
RQUAATWBAdd status dump facility - [12]
MHVIT4JYSplit hydra-queue-runner.cc more - [13]
HJOEIMLRRefactor - [14]
24BMQDZAStart of single-process hydra-queue-runner - [15]
OG3Z3QGCNamespace cleanup - [16]
IE2PRAQUhydra-queue-runner: Send build notifications - [17]
ARD6Z67TDo incremental SVN checkouts - [18]
FITVNQ2SKeep track of the time we spend copying to/from build machines - [19]
YJKSGJPCSet a default value for `getHydraPath'. - [20]
FQQRJUO4Mark builds as busy - [21]
5HFMGRVJDon't call buildFinished after we already know it failed - [22]
VQISTKOPhydra-queue-runner: Use substitutes - [23]
OOQ2D3KC* Refactoring: move fetchInput out of hydra_scheduler into a separate - [24]
7VQ4ALFYUpdate "make check" for the new queue runner - [25]
BRAESISHWarn if PostgreSQL appears stalled - [26]
NJJ7H64SVery basic multi-threaded queue runner - [27]
6WRGCITDEnable declarative projects. - [28]
K5G5GZY7Guard against concurrent invocations of hydra-queue-runner - [29]
GS4BE6TBAsynchronously compress build logs - [30]
RX5IIZMTUse Email::MIME instead of Email::Simple - [31]
62MQPRXCPass null values to libpqxx properly - [32]
UYUVQWXQFix hydra-queue-runner --build-one - [33]
IDFJXJHWrevert commit 26130, use hardcoded default value for HYDRA_DATA (/var/lib/hydra) - [34]
YDVFPMKPSecurity: Ensure that a build product refers to the Nix store - [35]
PHNLYPKBCall buildFinished when a cached build is added - [36]
Z52T2BC4Support passing a jobset evaluation as an input - [37]
IK2UBDAURevive jobset scheduling - [38]
B2L4T3X6Sync with Nix - [39]
PMNWRTGJAdd multiple output support - [40]
7VHPMFAGUse /usr/bin/env to find perl - [*]
5EQYVRWEAdd a plugin mechanism - [*]
BLVQGJ4LUse OO-style plugins - [*]
JAH3UPWASupport revision control systems via plugins
Change contents
- replacement in src/hydra-queue-runner/builder.cc at line 91
{auto notificationSenderQueue_(notificationSenderQueue.lock());notificationSenderQueue_->push(NotificationItem{NotificationItem::Type::Started, build->id});}notificationSenderWakeup.notify_one();enqueueNotificationItem({NotificationItem::Type::BuildStarted, build->id}); - replacement in src/hydra-queue-runner/builder.cc at line 106
int stepNr = 0;unsigned int stepNr = 0; - replacement in src/hydra-queue-runner/builder.cc at line 168
logCompressorQueue_->push(result.logFile);assert(stepNr);logCompressorQueue_->push({build->id, stepNr, result.logFile}); - replacement in src/hydra-queue-runner/builder.cc at line 269[5.8217]→[5.8217:8345](∅→∅),[5.8345]→[5.426:530](∅→∅),[5.530]→[5.8439:8514](∅→∅),[5.8439]→[5.8439:8514](∅→∅)
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}); - replacement in src/hydra-queue-runner/builder.cc at line 389
notificationSenderQueue_->push(NotificationItem{NotificationItem::Type::Finished, build->id, dependentIDs});notificationSenderQueue_->push(NotificationItem{NotificationItem::Type::BuildFinished, build->id, dependentIDs}); - replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 216
int State::allocBuildStep(pqxx::work & txn, Build::ptr build)unsigned int State::allocBuildStep(pqxx::work & txn, Build::ptr build) - replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 227
int State::createBuildStep(pqxx::work & txn, time_t startTime, Build::ptr build, Step::ptr step,unsigned int State::createBuildStep(pqxx::work & txn, time_t startTime, Build::ptr build, Step::ptr step, - replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 230
int stepNr = allocBuildStep(txn, build);unsigned int stepNr = allocBuildStep(txn, build); - replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 257
BuildID buildId, int stepNr, const std::string & machine, BuildStatus status,BuildID buildId, unsigned int stepNr, const std::string & machine, BuildStatus status, - replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 423
Path logPath;CompressionItem item; - replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 428
logPath = logCompressorQueue_->front();item = logCompressorQueue_->front(); - replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 432
if (!pathExists(logPath)) continue;if (!pathExists(item.logPath)) continue; - replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 434
printMsg(lvlChatty, format("compressing log file ‘%1%’") % logPath);printMsg(lvlChatty, format("compressing log file ‘%1%’") % item.logPath); - replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 436
Path tmpPath = logPath + ".bz2.tmp";Path dstPath = item.logPath + ".bz2";Path tmpPath = dstPath + ".tmp"; - replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 446
execlp("bzip2", "bzip2", "-c", logPath.c_str(), nullptr);execlp("bzip2", "bzip2", "-c", item.logPath.c_str(), nullptr); - replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 454
% res % logPath);% res % item.logPath); - replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 456
if (rename(tmpPath.c_str(), (logPath + ".bz2").c_str()) != 0)if (rename(tmpPath.c_str(), dstPath.c_str()) != 0) - replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 459
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 ensurethat the log file doesn't change while the plugins maybe accessing it. */enqueueNotificationItem({NotificationItem::Type::StepFinished, item.id, {}, item.stepNr, dstPath}); - replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 492
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;}; - replacement in src/hydra-queue-runner/state.hh at line 314
nix::Sync<std::queue<nix::Path>> logCompressorQueue;struct CompressionItem{BuildID id;unsigned int stepNr;nix::Path logPath;};nix::Sync<std::queue<CompressionItem>> logCompressorQueue; - replacement in src/hydra-queue-runner/state.hh at line 330
Started,FinishedBuildStarted,BuildFinished,StepFinished, - edit in src/hydra-queue-runner/state.hh at line 337
unsigned int stepNr;nix::Path logPath; - edit in src/hydra-queue-runner/state.hh at line 343
void enqueueNotificationItem(const NotificationItem && item){{auto notificationSenderQueue_(notificationSenderQueue.lock());notificationSenderQueue_->emplace(item);}notificationSenderWakeup.notify_one();} - replacement in src/hydra-queue-runner/state.hh at line 418
int allocBuildStep(pqxx::work & txn, Build::ptr build);unsigned int allocBuildStep(pqxx::work & txn, Build::ptr build); - replacement in src/hydra-queue-runner/state.hh at line 420
int createBuildStep(pqxx::work & txn, time_t startTime, Build::ptr build, Step::ptr step,unsigned int createBuildStep(pqxx::work & txn, time_t startTime, Build::ptr build, Step::ptr step, - replacement in src/hydra-queue-runner/state.hh at line 425
unsigned int overhead, BuildID buildId, int stepNr,unsigned int overhead, BuildID buildId, unsigned int stepNr, - file deletion: PluginHooks.pm
package Hydra::Helper::PluginHooks;use strict;use Exporter;our @ISA = qw(Exporter);our @EXPORT = qw(notifyBuildStartednotifyBuildFinished);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; - edit in src/lib/Hydra/Helper/AddBuilds.pm at line 19
use Hydra::Helper::PluginHooks; - edit in src/lib/Hydra/Plugin.pm at line 34[43.523][44.19153]
}# Called when step $step has finished. The build log is stored in the# file $logPath (bzip2-compressed).sub stepFinished {my ($self, $step, $logPath) = @_; - edit in src/script/hydra-notify at line 7
use Hydra::Helper::PluginHooks; - replacement in src/script/hydra-notify at line 18
my $cmd = shift @ARGV or die "Syntax: hydra-notify CMD BUILD-ID [BUILD-IDs...]\n";my $cmd = shift @ARGV or die "Syntax: hydra-notify build-started BUILD | build-finished BUILD-ID [BUILD-IDs...] | step-finished BUILD-ID STEP-NR LOG-PATH\n"; - edit in src/script/hydra-notify at line 23
- replacement in src/script/hydra-notify at line 36
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";}}