diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2020-06-15 00:39:03 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2020-06-15 00:39:03 +0200 |
commit | a295d69fcfabe64bd17ae05f1948505531ea99a2 (patch) | |
tree | 1d7e06f4f3e7219b160af3af9681262b42e8ff31 /modules/private/buildbot | |
parent | ce7d09efb55888501b73f9e763811deac762aed2 (diff) | |
download | Nix-a295d69fcfabe64bd17ae05f1948505531ea99a2.tar.gz Nix-a295d69fcfabe64bd17ae05f1948505531ea99a2.tar.zst Nix-a295d69fcfabe64bd17ae05f1948505531ea99a2.zip |
Add Denise websites
Diffstat (limited to 'modules/private/buildbot')
-rw-r--r-- | modules/private/buildbot/projects/denise/__init__.py | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/modules/private/buildbot/projects/denise/__init__.py b/modules/private/buildbot/projects/denise/__init__.py new file mode 100644 index 0000000..8809d3d --- /dev/null +++ b/modules/private/buildbot/projects/denise/__init__.py | |||
@@ -0,0 +1,72 @@ | |||
1 | from buildbot.plugins import * | ||
2 | from buildbot_common.build_helpers import * | ||
3 | import os | ||
4 | from buildbot.util import bytes2unicode | ||
5 | import json | ||
6 | |||
7 | __all__ = [ "configure", "E" ] | ||
8 | |||
9 | class E(): | ||
10 | PROJECT = "denise" | ||
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 | SSH_KEY_PATH = "/var/lib/buildbot/buildbot_key" | ||
15 | SSH_HOST_KEY = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIFbhFTl2A2RJn5L51yxJM4XfCS2ZaiSX/jo9jFSdghF" | ||
16 | |||
17 | OMS_RELEASE_PATH = "/var/lib/buildbot/outputs/denise_oms" | ||
18 | OMS_GIT_URL = "gitolite@git.immae.eu:perso/Denise/oms" | ||
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=denise,cn=buildbot,ou=services,dc=immae,dc=eu)(member=%(dn)s))" | ||
27 | TITLE_URL = "https://oms.syanni.eu" | ||
28 | TITLE = "Syanni website" | ||
29 | |||
30 | class 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 | |||
44 | def 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-denise")) | ||
52 | |||
53 | c['schedulers'].append(hook_scheduler("DeniseOMS", timer=1)) | ||
54 | c['schedulers'].append(force_scheduler("force_denise", [ | ||
55 | "DeniseOMS_build" | ||
56 | ])) | ||
57 | |||
58 | c['builders'].append(denise_oms_factory()) | ||
59 | |||
60 | def denise_oms_factory(): | ||
61 | factory = util.BuildFactory() | ||
62 | factory.addStep(steps.Git(logEnviron=False, repourl=E.OMS_GIT_URL, | ||
63 | submodules=True, sshPrivateKey=open(E.SSH_KEY_PATH).read().rstrip(), | ||
64 | sshHostKey=E.SSH_HOST_KEY, mode="full", method="copy")) | ||
65 | factory.addStep(steps.MasterShellCommand(command="rm -rf {}".format(E.OMS_RELEASE_PATH))) | ||
66 | factory.addStep(steps.DirectoryUpload(workersrc="../source", | ||
67 | masterdest=E.OMS_RELEASE_PATH, | ||
68 | url="https://oms.syanni.eu")) | ||
69 | factory.addStep(steps.MasterShellCommand(command="chmod -R a+rX {}".format(E.OMS_RELEASE_PATH))) | ||
70 | factory.addStep(steps.MasterShellCommand(command="kill $(cat /run/denise_oms/gunicorn.pid)")) | ||
71 | |||
72 | return util.BuilderConfig(name="DeniseOMS_build", workernames=["generic-worker-denise"], factory=factory) | ||