parent
27da79a92b
commit
f38fd1c826
|
@ -14,22 +14,16 @@ from os import walk
|
||||||
from os.path import exists, isfile, join, listdir
|
from os.path import exists, isfile, join, listdir
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
request_url = "https://buildbot.sysdeploy.org/change_hook/base"
|
ty = '/change_hook/base'
|
||||||
request_headers = {
|
request_headers = {
|
||||||
'Content-Type': 'application/x-www-form-urlencoded',
|
'Content-Type': 'application/x-www-form-urlencoded',
|
||||||
'Accept': 'text/plain'
|
'Accept': 'text/plain'
|
||||||
}
|
}
|
||||||
request_data = {
|
request_data = {
|
||||||
'repository': 'git@git.bitmessage.org:Sysdeploy/buildbot-scripts.git',
|
|
||||||
'project': 'testproject',
|
'project': 'testproject',
|
||||||
'author': 'cloud-init',
|
|
||||||
'comments': 'testcomment',
|
'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"):
|
def list_jobs(directory=".buildbot"):
|
||||||
"""
|
"""
|
||||||
|
@ -55,7 +49,8 @@ def find_artifacts(directory="out"):
|
||||||
continue
|
continue
|
||||||
return join(directory, _)
|
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
|
# List all jobs in the directory
|
||||||
jobs = list_jobs(directory)
|
jobs = list_jobs(directory)
|
||||||
|
@ -69,11 +64,26 @@ def trigger_child_hooks(directory=".buildbot"):
|
||||||
if exists(join(directory, job, "test.sh")):
|
if exists(join(directory, job, "test.sh")):
|
||||||
test_script_exists = True
|
test_script_exists = True
|
||||||
|
|
||||||
addn = addn.format(build_script_available=build_script_exists, test_script_available=test_script_exists)
|
|
||||||
|
|
||||||
# make a post request
|
# 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)
|
requests.post(request_url, headers=request_headers, data=request_data)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
trigger_child_hooks()
|
# 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 <jobname> <repository> <branch> <buildbotUrl>")
|
12
parent_hook
12
parent_hook
|
@ -2,7 +2,7 @@
|
||||||
""" parent webhook """
|
""" parent webhook """
|
||||||
|
|
||||||
from buildbot.plugins import steps, util, secrets
|
from buildbot.plugins import steps, util, secrets
|
||||||
from .lib.wine import *
|
from .lib.renderers import *
|
||||||
|
|
||||||
c = BuildmasterConfig = {}
|
c = BuildmasterConfig = {}
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ travis_bash.addStep(
|
||||||
name="Execute build script",
|
name="Execute build script",
|
||||||
command=[
|
command=[
|
||||||
"bash",
|
"bash",
|
||||||
util.Interpolate(".buildbot/$(prop:jobname)/build.sh"),
|
util.Interpolate(".buildbot/%(prop:jobname)s/build.sh"),
|
||||||
],
|
],
|
||||||
doStepIf=is_build_script_available,
|
doStepIf=is_build_script_available,
|
||||||
)
|
)
|
||||||
|
@ -55,7 +55,7 @@ travis_bash.addStep(
|
||||||
name="Execute test script",
|
name="Execute test script",
|
||||||
command=[
|
command=[
|
||||||
"bash",
|
"bash",
|
||||||
util.Interpolate(".buildbot/$(prop:jobname)/test.sh"),
|
util.Interpolate(".buildbot/%(prop:jobname)s/test.sh"),
|
||||||
],
|
],
|
||||||
doStepIf=is_test_script_available,
|
doStepIf=is_test_script_available,
|
||||||
)
|
)
|
||||||
|
@ -67,7 +67,11 @@ travis_bash.addStep(
|
||||||
name="Execute multibuild script",
|
name="Execute multibuild script",
|
||||||
command=[
|
command=[
|
||||||
"python",
|
"python",
|
||||||
util.Interpolate("multibuild.py"),
|
"multibuild.py",
|
||||||
|
util.Interpolate("%(prop:jobname)s"),
|
||||||
|
util.Property("repository"),
|
||||||
|
util.Property("branch"),
|
||||||
|
"https://buildbot.bitmessage.org",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user