From f38fd1c826293642fe7c61da61b2b86ef0a70466 Mon Sep 17 00:00:00 2001 From: Shashi Date: Thu, 23 Dec 2021 16:56:44 +0530 Subject: [PATCH] Updated-S --- lib/{wine.py => renderers.py} | 0 multibuild.py | 34 ++++++++++++++++++++++------------ parent_hook | 12 ++++++++---- 3 files changed, 30 insertions(+), 16 deletions(-) rename lib/{wine.py => renderers.py} (100%) diff --git a/lib/wine.py b/lib/renderers.py similarity index 100% rename from lib/wine.py rename to lib/renderers.py diff --git a/multibuild.py b/multibuild.py index 05eee87..3315d2e 100644 --- a/multibuild.py +++ b/multibuild.py @@ -14,22 +14,16 @@ from os import walk from os.path import exists, isfile, join, listdir import requests -request_url = "https://buildbot.sysdeploy.org/change_hook/base" +ty = '/change_hook/base' request_headers = { 'Content-Type': 'application/x-www-form-urlencoded', 'Accept': 'text/plain' } request_data = { - 'repository': 'git@git.bitmessage.org:Sysdeploy/buildbot-scripts.git', 'project': 'testproject', - 'author': 'cloud-init', 'comments': 'testcomment', } -ty = 'child_hook' -hn = 'buildbot.sysdeploy.org' #hostname here(required?) -addn = ',"build_script_available":"{build_script_available}","test_script_available":"{test_script_available}"' - def list_jobs(directory=".buildbot"): """ @@ -55,7 +49,8 @@ def find_artifacts(directory="out"): continue return join(directory, _) -def trigger_child_hooks(directory=".buildbot"): +def trigger_child_hooks(buildbotUrl:str, directory=".buildbot"): + request_url = buildbotUrl + ty # List all jobs in the directory jobs = list_jobs(directory) @@ -69,11 +64,26 @@ def trigger_child_hooks(directory=".buildbot"): if exists(join(directory, job, "test.sh")): test_script_exists = True - addn = addn.format(build_script_available=build_script_exists, test_script_available=test_script_exists) - # make a post request - request_data['properties'] = '{"node":{hn},"type":{ty}{addn}"}'.format(hn=hn, ty=ty, addn=addn) + request_data['dockerfile'] = open(join(directory, job, "Dockerfile"), "r").read() + request_data['build_script_available'] = str(build_script_exists) + request_data['test_script_available'] = str(test_script_exists) requests.post(request_url, headers=request_headers, data=request_data) if __name__ == "__main__": - trigger_child_hooks() \ No newline at end of file + # expect jobname, repository, branch from command line args + import sys + if len(sys.argv) == 5: + jobname = sys.argv[1] + repository = sys.argv[2] + branch = sys.argv[3] + buildbotUrl = sys.argv[4] + + # add these into the request_data + request_data['jobname'] = jobname + request_data['repository'] = repository + request_data['branch'] = branch + + trigger_child_hooks(buildbotUrl) + else: + print("Usage: python3 multibuild.py ") \ No newline at end of file diff --git a/parent_hook b/parent_hook index aace749..4863696 100644 --- a/parent_hook +++ b/parent_hook @@ -2,7 +2,7 @@ """ parent webhook """ from buildbot.plugins import steps, util, secrets -from .lib.wine import * +from .lib.renderers import * c = BuildmasterConfig = {} @@ -44,7 +44,7 @@ travis_bash.addStep( name="Execute build script", command=[ "bash", - util.Interpolate(".buildbot/$(prop:jobname)/build.sh"), + util.Interpolate(".buildbot/%(prop:jobname)s/build.sh"), ], doStepIf=is_build_script_available, ) @@ -55,7 +55,7 @@ travis_bash.addStep( name="Execute test script", command=[ "bash", - util.Interpolate(".buildbot/$(prop:jobname)/test.sh"), + util.Interpolate(".buildbot/%(prop:jobname)s/test.sh"), ], doStepIf=is_test_script_available, ) @@ -67,7 +67,11 @@ travis_bash.addStep( name="Execute multibuild script", command=[ "python", - util.Interpolate("multibuild.py"), + "multibuild.py", + util.Interpolate("%(prop:jobname)s"), + util.Property("repository"), + util.Property("branch"), + "https://buildbot.bitmessage.org", ], ) )