__all__ = [
"force_scheduler", "deploy_scheduler", "git_hook_scheduler",
- "clean_branch", "package_and_upload", "SlackStatusPush",
+ "clean_branch", "package_and_upload", "AppriseStatusPush",
"XMPPStatusPush", "NixShellCommand",
"all_builder_names", "compute_build_infos", "deploy_ssh_command",
- "configure_slack_push", "configure_xmpp_push", "deploy_hook_scheduler",
+ "configure_apprise_push",
+ "configure_xmpp_push", "deploy_hook_scheduler",
]
# Small helpers"
def all_builder_names(c):
return [builder.name for builder in c['builders']]
-# Slack/XMPP status push
+# Apprise/XMPP status push
from buildbot.reporters.http import HttpStatusPushBase
from twisted.internet import defer
from twisted.python import log
-from buildbot.util import httpclientservice
from buildbot.reporters import utils
from buildbot.process import results
from twisted.words.protocols.jabber.jid import JID
from wokkel import client, xmppim
from functools import partial
+import apprise
-class SlackStatusPush(HttpStatusPushBase):
- name = "SlackStatusPush"
+class AppriseStatusPush(HttpStatusPushBase):
+ name = "AppriseStatusPush"
@defer.inlineCallbacks
- def reconfigService(self, serverUrl, **kwargs):
+ def reconfigService(self, appriseUrls, **kwargs):
+ self.appriseUrls = appriseUrls
yield HttpStatusPushBase.reconfigService(self, **kwargs)
- self._http = yield httpclientservice.HTTPClientService.getService(
- self.master, serverUrl)
@defer.inlineCallbacks
def send(self, build):
yield utils.getDetailsForBuild(self.master, build, wantProperties=True)
- response = yield self._http.post("", json=self.format(build))
- if response.code != 200:
- log.msg("%s: unable to upload status: %s" %
- (response.code, response.content))
+ appobject = apprise.Apprise()
+ message = self.format(build)
+ for url in self.appriseUrls:
+ appobject.add(url.format(**message))
+ yield appobject.notify(title=message["title"], body=message["text"])
def format(self, build):
- colors = [
- "#36A64F", # success
- "#F1E903", # warnings
- "#DA0505", # failure
- "#FFFFFF", # skipped
- "#000000", # exception
- "#FFFFFF", # retry
- "#D02CA9", # cancelled
- ]
-
if "environment" in build["properties"]:
msg = "{} environment".format(build["properties"]["environment"][0])
if "build" in build["properties"]:
else:
duration = "{}s".format(seconds)
- text = "Build <{}|{}> of {}'s {} was {} in {}.".format(
- build["url"], build["buildid"],
+ text = "Build {} ({}) of {}'s {} was {} in {}.".format(
+ build["number"], build["url"],
build["builder"]["name"],
msg,
results.Results[build["results"]],
duration,
)
- fields = [
- {
- "title": "Build",
- "value": "<{}|{}>".format(build["url"], build["buildid"]),
- "short": True,
- },
- {
- "title": "Project",
- "value": build["builder"]["name"],
- "short": True,
- },
- {
- "title": "Build status",
- "value": results.Results[build["results"]],
- "short": True,
- },
- {
- "title": "Build duration",
- "value": duration,
- "short": True,
- },
- ]
- if "environment" in build["properties"]:
- fields.append({
- "title": "Environment",
- "value": build["properties"]["environment"][0],
- "short": True,
- })
- if "build" in build["properties"]:
- fields.append({
- "title": "Archive",
- "value": build["properties"]["build"][0],
- "short": True,
- })
- attachments = [{
- "fallback": "",
- "color": colors[build["results"]],
- "fields": fields
- }]
else:
- text = "Build <{}|{}> of {}'s {} started.".format(
- build["url"], build["buildid"],
+ text = "Build {} ({}) of {}'s {} started.".format(
+ build["number"], build["url"],
build["builder"]["name"],
msg,
)
- attachments = []
-
return {
"username": "Buildbot",
- "icon_url": "http://docs.buildbot.net/current/_static/icon.png",
+ "image_url": "http://docs.buildbot.net/current/_static/icon.png",
"text": text,
- "attachments": attachments,
+ "title": "",
}
-def configure_slack_push(c, secrets_file, builders):
- c['services'].append(SlackStatusPush(
- name="slack_status", builders=builders,
- serverUrl=open(secrets_file + "/slack_webhook", "r").read().rstrip()))
+def configure_apprise_push(c, secrets_file, builders):
+ c['services'].append(AppriseStatusPush(
+ name="apprise_status", builders=builders,
+ appriseUrls=open(secrets_file + "/apprise_webhooks", "r").read().split("\n")))
class XMPPStatusPush(HttpStatusPushBase):
name = "XMPPStatusPush"
duration = "{}s".format(seconds)
text = "Build {} ( {} ) of {}'s {} was {} in {}.".format(
- build["buildid"], build["url"],
+ build["number"], build["url"],
build["builder"]["name"],
msg,
results.Results[build["results"]],
)
else:
text = "Build {} ( {} ) of {}'s {} started.".format(
- build["buildid"], build["url"],
+ build["number"], build["url"],
build["builder"]["name"],
msg,
)
};
notify-primary = {
resources = {
- USER206 = config.myEnv.monitoring.slack_channel;
- USER207 = config.myEnv.monitoring.slack_url;
+ USER210 = config.myEnv.monitoring.apprise_urls;
};
commands = {
# $OVE is to force naemon to run via shell instead of execve which fails here
notify-host-by-email = "ADMINEMAIL=\"$ADMINEMAIL$\" SERVICENOTIFICATIONID=\"$SERVICENOTIFICATIONID$\" HOSTSTATE=\"$HOSTSTATE$\" HOSTOUTPUT=\"$HOSTOUTPUT$\" $USER2$/notify_by_email host \"$NOTIFICATIONTYPE$\" \"$HOSTALIAS$\" \"$LONGDATETIME$\" \"$CONTACTEMAIL$\" $OVE";
# $OVE is to force naemon to run via shell instead of execve which fails here
notify-service-by-email = "ADMINEMAIL=\"$ADMINEMAIL$\" SERVICENOTIFICATIONID=\"$SERVICENOTIFICATIONID$\" SERVICEDESC=\"$SERVICEDESC$\" SERVICESTATE=\"$SERVICESTATE$\" SERVICEOUTPUT=\"$SERVICEOUTPUT$\" $USER2$/notify_by_email service \"$NOTIFICATIONTYPE$\" \"$HOSTALIAS$\" \"$LONGDATETIME$\" \"$CONTACTEMAIL$\" $OVE";
- notify-by-slack = "HOST=\"$HOSTALIAS$\" SERVICESTATE=\"$SERVICESTATE$\" SERVICEDESC=\"$SERVICEDESC$\" SERVICEOUTPUT=\"$SERVICEOUTPUT$\" $USER2$/notify_by_slack \"$ARG1$\" \"$ARG2$\"";
+ notify-host-by-apprise = "HOST=\"$HOSTALIAS$\" NOTIFICATIONTYPE=\"$NOTIFICATIONTYPE$\" HOSTSTATE=\"$HOSTSTATE$\" HOSTOUTPUT=\"$HOSTOUTPUT$\" $USER2$/notify_by_apprise host \"$ARG1$\"";
+ notify-service-by-apprise = "HOST=\"$HOSTALIAS$\" NOTIFICATIONTYPE=\"$NOTIFICATIONTYPE$\" SERVICESTATE=\"$SERVICESTATE$\" SERVICEDESC=\"$SERVICEDESC$\" SERVICEOUTPUT=\"$SERVICEOUTPUT$\" $USER2$/notify_by_apprise service \"$ARG1$\"";
};
chunk = ''
- cp ${./plugins}/{notify_by_email,notify_by_slack} $out
- patchShebangs $out/{notify_by_email,notify_by_slack}
+ cp ${./plugins}/{notify_by_email,notify_by_apprise} $out
+ patchShebangs $out/{notify_by_email,notify_by_apprise}
wrapProgram $out/notify_by_email --prefix PATH : ${lib.makeBinPath [
pkgs.mailutils
]}
- wrapProgram $out/notify_by_slack --prefix PATH : ${lib.makeBinPath [
- pkgs.curl pkgs.jq
+ wrapProgram $out/notify_by_apprise --prefix PATH : ${lib.makeBinPath [
+ pkgs.apprise
]}
'';
};