Add buildStarted plugin hook
This commit is contained in:
@ -84,9 +84,16 @@ State::StepResult State::doBuildStep(nix::ref<Store> destStore, Step::ptr step,
|
||||
return sMaybeCancelled;
|
||||
}
|
||||
|
||||
for (auto build2 : dependents)
|
||||
if (build2->drvPath == step->drvPath) { build = build2; break; }
|
||||
|
||||
for (auto build2 : dependents) {
|
||||
if (build2->drvPath == step->drvPath) {
|
||||
build = build2;
|
||||
{
|
||||
auto notificationSenderQueue_(notificationSenderQueue.lock());
|
||||
notificationSenderQueue_->push(NotificationItem{NotificationItem::Type::Started, build->id});
|
||||
}
|
||||
notificationSenderWakeup.notify_one();
|
||||
}
|
||||
}
|
||||
if (!build) build = *dependents.begin();
|
||||
|
||||
printMsg(lvlInfo, format("performing step ‘%1%’ on ‘%2%’ (needed by build %3% and %4% others)")
|
||||
@ -249,7 +256,7 @@ State::StepResult State::doBuildStep(nix::ref<Store> destStore, Step::ptr step,
|
||||
for (auto id : buildIDs) {
|
||||
{
|
||||
auto notificationSenderQueue_(notificationSenderQueue.lock());
|
||||
notificationSenderQueue_->push(NotificationItem(id, std::vector<BuildID>()));
|
||||
notificationSenderQueue_->push(NotificationItem{NotificationItem::Type::Finished, id});
|
||||
}
|
||||
notificationSenderWakeup.notify_one();
|
||||
}
|
||||
@ -369,7 +376,7 @@ State::StepResult State::doBuildStep(nix::ref<Store> destStore, Step::ptr step,
|
||||
/* Send notification about this build and its dependents. */
|
||||
{
|
||||
auto notificationSenderQueue_(notificationSenderQueue.lock());
|
||||
notificationSenderQueue_->push(NotificationItem(build->id, dependentIDs));
|
||||
notificationSenderQueue_->push(NotificationItem{NotificationItem::Type::Finished, build->id, dependentIDs});
|
||||
}
|
||||
notificationSenderWakeup.notify_one();
|
||||
|
||||
|
@ -482,11 +482,11 @@ void State::notificationSender()
|
||||
notificationSenderQueue_->pop();
|
||||
}
|
||||
|
||||
printMsg(lvlChatty, format("sending notification about build %1%") % item.first);
|
||||
printMsg(lvlChatty, format("sending notification about build %1%") % item.id);
|
||||
|
||||
Pid pid = startProcess([&]() {
|
||||
Strings argv({"hydra-notify", "build", std::to_string(item.first)});
|
||||
for (auto id : item.second)
|
||||
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));
|
||||
execvp("hydra-notify", (char * *) stringsToCharPtrs(argv).data()); // FIXME: remove cast
|
||||
throw SysError("cannot start hydra-notify");
|
||||
@ -496,7 +496,7 @@ void State::notificationSender()
|
||||
|
||||
if (res != 0)
|
||||
throw Error(format("hydra-build returned exit code %1% notifying about build %2%")
|
||||
% res % item.first);
|
||||
% res % item.id);
|
||||
|
||||
} catch (std::exception & e) {
|
||||
printMsg(lvlError, format("notification sender: %1%") % e.what());
|
||||
|
@ -318,7 +318,16 @@ private:
|
||||
killed before it has finished sending notifications about a
|
||||
build, then the notifications may be lost. It would be better
|
||||
to mark builds with pending notification in the database. */
|
||||
typedef std::pair<BuildID, std::vector<BuildID>> NotificationItem;
|
||||
struct NotificationItem
|
||||
{
|
||||
enum class Type : char {
|
||||
Started,
|
||||
Finished
|
||||
};
|
||||
Type type;
|
||||
BuildID id;
|
||||
std::vector<BuildID> dependentIds;
|
||||
};
|
||||
nix::Sync<std::queue<NotificationItem>> notificationSenderQueue;
|
||||
std::condition_variable notificationSenderWakeup;
|
||||
|
||||
|
Reference in New Issue
Block a user