aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/private/buildbot/default.nix6
-rw-r--r--modules/private/buildbot/projects/immaeEu/__init__.py82
-rw-r--r--modules/private/websites/immae/production.nix7
3 files changed, 88 insertions, 7 deletions
diff --git a/modules/private/buildbot/default.nix b/modules/private/buildbot/default.nix
index 88bab9b..0e63337 100644
--- a/modules/private/buildbot/default.nix
+++ b/modules/private/buildbot/default.nix
@@ -68,7 +68,11 @@ in
68 68
69 system.activationScripts = lib.attrsets.mapAttrs' (k: project: lib.attrsets.nameValuePair "buildbot-${project.name}" { 69 system.activationScripts = lib.attrsets.mapAttrs' (k: project: lib.attrsets.nameValuePair "buildbot-${project.name}" {
70 deps = [ "users" "wrappers" ]; 70 deps = [ "users" "wrappers" ];
71 text = project.activationScript; 71 text = ''
72 install -m 755 -o buildbot -g buildbot -d ${varDir}/${project.name}
73
74 ${project.activationScript}
75 '';
72 }) myconfig.env.buildbot.projects; 76 }) myconfig.env.buildbot.projects;
73 77
74 secrets.keys = ( 78 secrets.keys = (
diff --git a/modules/private/buildbot/projects/immaeEu/__init__.py b/modules/private/buildbot/projects/immaeEu/__init__.py
new file mode 100644
index 0000000..23ac970
--- /dev/null
+++ b/modules/private/buildbot/projects/immaeEu/__init__.py
@@ -0,0 +1,82 @@
1from buildbot.plugins import *
2from buildbot_common.build_helpers import *
3import os
4from buildbot.util import bytes2unicode
5import json
6
7__all__ = [ "configure", "E" ]
8
9class E():
10 PROJECT = "immaeEu"
11 BUILDBOT_URL = "https://git.immae.eu/buildbot/{}/".format(PROJECT)
12 SOCKET = "unix:/run/buildbot/{}.sock".format(PROJECT)
13 PB_SOCKET = "unix:address=/run/buildbot/{}_pb.sock".format(PROJECT)
14 RELEASE_PATH = "/var/lib/buildbot/outputs/immaeEu"
15 GIT_URL = "gitolite@git.immae.eu:perso/Immae/Sites/Blog"
16 SSH_KEY_PATH = "/var/lib/buildbot/buildbot_key"
17 SSH_HOST_KEY = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIFbhFTl2A2RJn5L51yxJM4XfCS2ZaiSX/jo9jFSdghF"
18 XMPP_RECIPIENTS = os.environ["BUILDBOT_XMPP_RECIPIENTS"].split(" ")
19
20 # master.cfg
21 SECRETS_FILE = os.getcwd() + "/secrets"
22 LDAP_URL = "ldaps://ldap.immae.eu:636"
23 LDAP_ADMIN_USER = "cn=buildbot,ou=services,dc=immae,dc=eu"
24 LDAP_BASE = "dc=immae,dc=eu"
25 LDAP_PATTERN = "(uid=%(username)s)"
26 LDAP_GROUP_PATTERN = "(&(memberOf=cn=groups,ou=immaeEu,cn=buildbot,ou=services,dc=immae,dc=eu)(member=%(dn)s))"
27 TITLE_URL = "https://www.immae.eu"
28 TITLE = "Immae website"
29
30class CustomBase(webhooks.base):
31 def getChanges(self, request):
32 try:
33 content = request.content.read()
34 args = json.loads(bytes2unicode(content))
35 except Exception as e:
36 raise ValueError("Error loading JSON: " + str(e))
37
38 args.setdefault("comments", "")
39 args.setdefault("repository", "")
40 args.setdefault("author", args.get("who", "unknown"))
41
42 return ([args], None)
43
44def configure(c):
45 c["buildbotURL"] = E.BUILDBOT_URL
46 c["www"]["port"] = E.SOCKET
47
48 c["www"]["change_hook_dialects"]["base"] = {
49 "custom_class": CustomBase
50 }
51 c['workers'].append(worker.LocalWorker("generic-worker-immae-eu"))
52
53 c['schedulers'].append(hook_scheduler("ImmaeEu", timer=1))
54 c['schedulers'].append(force_scheduler("force_immae_eu", ["ImmaeEu_build"]))
55
56 c['builders'].append(factory())
57
58 c['services'].append(SlackStatusPush(
59 name="slack_status_immae_eu_project",
60 builders=["ImmaeEu_build"],
61 serverUrl=open(E.SECRETS_FILE + "/slack_webhook", "r").read().rstrip()))
62 c['services'].append(XMPPStatusPush(
63 name="xmpp_status_immae_eu_project",
64 builders=["ImmaeEu_build"],
65 recipients=E.XMPP_RECIPIENTS,
66 password=open(E.SECRETS_FILE + "/notify_xmpp_password", "r").read().rstrip()))
67
68def factory():
69 factory = util.BuildFactory()
70 factory.addStep(steps.Git(logEnviron=False, repourl=E.GIT_URL,
71 sshPrivateKey=open(E.SSH_KEY_PATH).read().rstrip(),
72 sshHostKey=E.SSH_HOST_KEY, mode="full", method="copy"))
73 factory.addStep(steps.ShellCommand(name="build website",
74 logEnviron=False, haltOnFailure=True, workdir="source",
75 command=["make", "html"]))
76 factory.addStep(steps.MasterShellCommand(command="rm -rf {}".format(E.RELEASE_PATH)))
77 factory.addStep(steps.DirectoryUpload(workersrc="../source/output",
78 masterdest=E.RELEASE_PATH,
79 url="https://www.immae.eu"))
80 factory.addStep(steps.MasterShellCommand(command="chmod -R a+rX {}".format(E.RELEASE_PATH)))
81
82 return util.BuilderConfig(name="ImmaeEu_build", workernames=["generic-worker-immae-eu"], factory=factory)
diff --git a/modules/private/websites/immae/production.nix b/modules/private/websites/immae/production.nix
index 6b88ff2..e02d026 100644
--- a/modules/private/websites/immae/production.nix
+++ b/modules/private/websites/immae/production.nix
@@ -1,7 +1,7 @@
1{ lib, pkgs, config, myconfig, ... }: 1{ lib, pkgs, config, myconfig, ... }:
2let 2let
3 cfg = config.myServices.websites.immae.production; 3 cfg = config.myServices.websites.immae.production;
4 varDir = "/var/lib/ftp/immae"; 4 varDir = "/var/lib/buildbot/outputs/immaeEu";
5 env = myconfig.env.websites.immae; 5 env = myconfig.env.websites.immae;
6in { 6in {
7 options.myServices.websites.immae.production.enable = lib.mkEnableOption "enable Immae's website"; 7 options.myServices.websites.immae.production.enable = lib.mkEnableOption "enable Immae's website";
@@ -24,11 +24,6 @@ in {
24 AllowOverride All 24 AllowOverride All
25 Require all granted 25 Require all granted
26 </Directory> 26 </Directory>
27
28 <Location /blog_old/>
29 Use LDAPConnect
30 Require ldap-group cn=blog,cn=immae.eu,ou=services,dc=immae,dc=eu
31 </Location>
32 '' 27 ''
33 ]; 28 ];
34 }; 29 };