Added parent hook and some renderer
This commit is contained in:
parent
806761eda7
commit
27da79a92b
38
lib/wine.py
Normal file
38
lib/wine.py
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
from buildbot.plugins import util
|
||||||
|
import re
|
||||||
|
|
||||||
|
def _is_github(props):
|
||||||
|
if re.search(r'[/@]github.com', props.getProperty('repository')):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
@util.renderer
|
||||||
|
def is_github(props):
|
||||||
|
return _is_github(props)
|
||||||
|
|
||||||
|
@util.renderer
|
||||||
|
def isnt_github(props):
|
||||||
|
return not _is_github(props)
|
||||||
|
|
||||||
|
def _is_gitea(props):
|
||||||
|
if re.search(r'[/@]git.bitmessage.org', props.getProperty('repository'), re.I):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
@util.renderer
|
||||||
|
def is_gitea(props):
|
||||||
|
return _is_gitea(props)
|
||||||
|
|
||||||
|
@util.renderer
|
||||||
|
def isnt_gitea(props):
|
||||||
|
return not _is_gitea(props)
|
||||||
|
|
||||||
|
@util.renderer
|
||||||
|
def is_build_script_available(props):
|
||||||
|
# Actual check will got here
|
||||||
|
return props.getProperty('jobname', default='') != ''
|
||||||
|
|
||||||
|
@util.renderer
|
||||||
|
def is_test_script_available(props):
|
||||||
|
# Actual check will got here
|
||||||
|
return props.getProperty('jobname', default='') != ''
|
|
@ -12,6 +12,23 @@ Requires docker
|
||||||
|
|
||||||
from os import walk
|
from os import walk
|
||||||
from os.path import exists, isfile, join, listdir
|
from os.path import exists, isfile, join, listdir
|
||||||
|
import requests
|
||||||
|
|
||||||
|
request_url = "https://buildbot.sysdeploy.org/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"):
|
def list_jobs(directory=".buildbot"):
|
||||||
|
@ -37,3 +54,26 @@ def find_artifacts(directory="out"):
|
||||||
if not isfile(join(directory, _)):
|
if not isfile(join(directory, _)):
|
||||||
continue
|
continue
|
||||||
return join(directory, _)
|
return join(directory, _)
|
||||||
|
|
||||||
|
def trigger_child_hooks(directory=".buildbot"):
|
||||||
|
|
||||||
|
# List all jobs in the directory
|
||||||
|
jobs = list_jobs(directory)
|
||||||
|
|
||||||
|
# Check if build.sh or test.sh exists in each of the jobs
|
||||||
|
for job in jobs:
|
||||||
|
build_script_exists = False
|
||||||
|
test_script_exists = False
|
||||||
|
if exists(join(directory, job, "build.sh")):
|
||||||
|
build_script_exists = True
|
||||||
|
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)
|
||||||
|
requests.post(request_url, headers=request_headers, data=request_data)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
trigger_child_hooks()
|
73
parent_hook
Normal file
73
parent_hook
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
""" parent webhook """
|
||||||
|
|
||||||
|
from buildbot.plugins import steps, util, secrets
|
||||||
|
from .lib.wine import *
|
||||||
|
|
||||||
|
c = BuildmasterConfig = {}
|
||||||
|
|
||||||
|
c['buildbotNetUsageData'] = None
|
||||||
|
|
||||||
|
####### SECRETS
|
||||||
|
|
||||||
|
c['secretsProviders'] = [secrets.SecretInAFile(dirname="/var/lib/buildbot/secrets/bitmessage")]
|
||||||
|
gitea_known_hosts = util.Secret('gitea_known_hosts')
|
||||||
|
gitea_privkey = util.Secret('gitea_privkey')
|
||||||
|
|
||||||
|
travis_bash = util.BuildFactory()
|
||||||
|
travis_bash.addStep(
|
||||||
|
steps.GitHub(
|
||||||
|
repourl=util.Property("repository"),
|
||||||
|
name="github",
|
||||||
|
doStepIf=is_github,
|
||||||
|
hideStepIf=isnt_github,
|
||||||
|
branch=util.Property("branch"),
|
||||||
|
mode="incremental",
|
||||||
|
)
|
||||||
|
)
|
||||||
|
travis_bash.addStep(
|
||||||
|
steps.Gitea(
|
||||||
|
repourl=util.Property("repository"),
|
||||||
|
sshPrivateKey=gitea_privkey,
|
||||||
|
sshKnownHosts=gitea_known_hosts,
|
||||||
|
name="gitea",
|
||||||
|
doStepIf=is_gitea,
|
||||||
|
hideStepIf=isnt_gitea,
|
||||||
|
branch=util.Property("branch"),
|
||||||
|
mode="incremental",
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
# execute an interpolate of '.buildbot/$(prop:jobname)/build.sh'
|
||||||
|
travis_bash.addStep(
|
||||||
|
steps.ShellCommand(
|
||||||
|
name="Execute build script",
|
||||||
|
command=[
|
||||||
|
"bash",
|
||||||
|
util.Interpolate(".buildbot/$(prop:jobname)/build.sh"),
|
||||||
|
],
|
||||||
|
doStepIf=is_build_script_available,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
travis_bash.addStep(
|
||||||
|
steps.ShellCommand(
|
||||||
|
name="Execute test script",
|
||||||
|
command=[
|
||||||
|
"bash",
|
||||||
|
util.Interpolate(".buildbot/$(prop:jobname)/test.sh"),
|
||||||
|
],
|
||||||
|
doStepIf=is_test_script_available,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
# execute multibuild.py
|
||||||
|
travis_bash.addStep(
|
||||||
|
steps.ShellCommand(
|
||||||
|
name="Execute multibuild script",
|
||||||
|
command=[
|
||||||
|
"python",
|
||||||
|
util.Interpolate("multibuild.py"),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
)
|
Loading…
Reference in New Issue
Block a user