aboutsummaryrefslogtreecommitdiff
path: root/nixops/modules/buildbot/projects/test
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2019-03-26 01:31:24 +0100
committerIsmaël Bouya <ismael.bouya@normalesup.org>2019-03-26 10:45:04 +0100
commit85817848f29f1e2c3680da216a8dfc54a2ad3932 (patch)
tree21a57b50106701fa461a3767429b5a9f532138cb /nixops/modules/buildbot/projects/test
parent587b9e340bb5cb14ca55e62a0498295e702b56c5 (diff)
downloadNix-85817848f29f1e2c3680da216a8dfc54a2ad3932.tar.gz
Nix-85817848f29f1e2c3680da216a8dfc54a2ad3932.tar.zst
Nix-85817848f29f1e2c3680da216a8dfc54a2ad3932.zip
Add deploy webhook
Diffstat (limited to 'nixops/modules/buildbot/projects/test')
-rw-r--r--nixops/modules/buildbot/projects/test/__init__.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/nixops/modules/buildbot/projects/test/__init__.py b/nixops/modules/buildbot/projects/test/__init__.py
index adda289..0644920 100644
--- a/nixops/modules/buildbot/projects/test/__init__.py
+++ b/nixops/modules/buildbot/projects/test/__init__.py
@@ -1,6 +1,8 @@
1from buildbot.plugins import * 1from buildbot.plugins import *
2from buildbot_common.build_helpers import * 2from buildbot_common.build_helpers import *
3import os 3import os
4from buildbot.util import bytes2unicode
5import json
4 6
5__all__ = [ "configure", "E" ] 7__all__ = [ "configure", "E" ]
6 8
@@ -28,16 +30,52 @@ class E():
28 TITLE_URL = "https://git.immae.eu/?p=perso/Immae/TestProject.git;a=summary" 30 TITLE_URL = "https://git.immae.eu/?p=perso/Immae/TestProject.git;a=summary"
29 TITLE = "Test project" 31 TITLE = "Test project"
30 32
33class CustomBase(webhooks.base):
34 def getChanges(self, request):
35 try:
36 content = request.content.read()
37 args = json.loads(bytes2unicode(content))
38 except Exception as e:
39 raise ValueError("Error loading JSON: " + str(e))
40
41 args.setdefault("comments", "")
42 args.setdefault("repository", "")
43 args.setdefault("author", args.get("who", "unknown"))
44
45 if args["category"] == "deploy_webhook":
46 args = {
47 "category": "deploy_webhook",
48 "comments": "",
49 "repository": "",
50 "author": "unknown",
51 "project": "TestProject",
52 "properties": {
53 "environment": args.get("environment", "integration"),
54 "build": "test_{}.tar.gz".format(args.get("branch", "master"))
55 }
56 }
57
58 return ([args], None)
59
60def deploy_hook_scheduler(project, timer=1):
61 return schedulers.AnyBranchScheduler(
62 change_filter=util.ChangeFilter(category="deploy_webhook", project=project),
63 name="{}_deploy".format(project), treeStableTimer=timer, builderNames=["{}_deploy".format(project)])
64
31def configure(c): 65def configure(c):
32 c["buildbotURL"] = E.BUILDBOT_URL 66 c["buildbotURL"] = E.BUILDBOT_URL
33 c["www"]["port"] = E.SOCKET 67 c["www"]["port"] = E.SOCKET
34 68
69 c["www"]["change_hook_dialects"]["base"] = {
70 "custom_class": CustomBase
71 }
35 c['workers'].append(worker.LocalWorker("generic-worker-test")) 72 c['workers'].append(worker.LocalWorker("generic-worker-test"))
36 c['workers'].append(worker.LocalWorker("deploy-worker-test")) 73 c['workers'].append(worker.LocalWorker("deploy-worker-test"))
37 74
38 c['schedulers'].append(hook_scheduler("TestProject", timer=1)) 75 c['schedulers'].append(hook_scheduler("TestProject", timer=1))
39 c['schedulers'].append(force_scheduler("force_test", ["TestProject_build"])) 76 c['schedulers'].append(force_scheduler("force_test", ["TestProject_build"]))
40 c['schedulers'].append(deploy_scheduler("deploy_test", ["TestProject_deploy"])) 77 c['schedulers'].append(deploy_scheduler("deploy_test", ["TestProject_deploy"]))
78 c['schedulers'].append(deploy_hook_scheduler("TestProject", timer=1))
41 79
42 c['builders'].append(factory()) 80 c['builders'].append(factory())
43 c['builders'].append(deploy_factory()) 81 c['builders'].append(deploy_factory())