changes for worker

This commit is contained in:
Muzahid 2022-02-17 22:09:45 +05:30
parent f55b088897
commit 6d819cee55
Signed by: cis-muzahid
GPG Key ID: 1DC85E7D3AB613EA
2 changed files with 11 additions and 25 deletions

View File

@ -2,7 +2,6 @@ from os import listdir, walk
from os.path import exists, isfile, join
import requests
import re
from buildbot.plugins import util
from .renderers import *
@ -71,11 +70,11 @@ def list_jobs(directory=".buildbot"):
return results
def _get_dockerfile_contents(props):
def _get_dockerfile_contents(props, jobname, os_codename):
"""
Read contents of a Dockerfile and add extra contents for the given os_codename
"""
with open(join(path + props.getProperty('jobname', default=None)), "r") as file:
with open(join(path + jobname), "r") as file:
contents = file.read()
# remove any line containing CMD or ENTRYFILE keywords
re.sub(r"(?m)^(CMD|ENTRYFILE).*$", "", contents)
@ -83,12 +82,7 @@ def _get_dockerfile_contents(props):
return contents + {
"focal": dockerfile_extra_contents_focal,
"bionic": dockerfile_extra_contents_bionic,
}[util.Interpolate("%(prop:os_codename)s")]
@util.renderer
def get_dockerfile_contents(props):
return _get_dockerfile_contents(props)
}[os_codename]
def trigger_child_hooks(buildbotUrl: str, os_codename: str, repository, branch, jobname, directory=".buildbot"):
@ -108,7 +102,7 @@ def trigger_child_hooks(buildbotUrl: str, os_codename: str, repository, branch,
# make a post request
request_data["properties"] = {
"dockerfile": get_dockerfile_contents(
"dockerfile": _get_dockerfile_contents(
join(directory, job, "Dockerfile"), os_codename
),
"build_script_available": is_build_script_available(build_script_exists),

View File

@ -17,22 +17,11 @@ import re
from buildbot.plugins import steps, util
from .lib.renderers import *
from .lib.worker_multibuild import trigger_child_hooks
def list_jobs(directory=".buildbot"):
"""
list jobs found in a directory
"""
results = []
for _ in next(walk(directory))[1]:
if exists(join(directory, _, "Dockerfile")) and (
exists(join(directory, _, "build.sh"))
or exists(join(directory, _, "test.sh"))
):
results.append(_)
return results
addStep(steps.ShellCommand(
name="download worker",
command=["sudo", "wget", "-O", "lib/worker_multibuild.py", "worker_multibuild.py"]
))
def find_artifacts(directory="out"):
@ -45,6 +34,9 @@ def find_artifacts(directory="out"):
return join(directory, _)
@util.renderer
def get_dockerfile_contents(props):
return _get_dockerfile_contents(props, props.getProperty('jobname', default=None), util.Interpolate("%(prop:os_codename)s"))
def add_parent_step(build_factory):