changes for worker
This commit is contained in:
parent
f55b088897
commit
6d819cee55
|
@ -2,7 +2,6 @@ from os import listdir, walk
|
||||||
from os.path import exists, isfile, join
|
from os.path import exists, isfile, join
|
||||||
import requests
|
import requests
|
||||||
import re
|
import re
|
||||||
from buildbot.plugins import util
|
|
||||||
from .renderers import *
|
from .renderers import *
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,11 +70,11 @@ def list_jobs(directory=".buildbot"):
|
||||||
return results
|
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
|
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()
|
contents = file.read()
|
||||||
# remove any line containing CMD or ENTRYFILE keywords
|
# remove any line containing CMD or ENTRYFILE keywords
|
||||||
re.sub(r"(?m)^(CMD|ENTRYFILE).*$", "", contents)
|
re.sub(r"(?m)^(CMD|ENTRYFILE).*$", "", contents)
|
||||||
|
@ -83,12 +82,7 @@ def _get_dockerfile_contents(props):
|
||||||
return contents + {
|
return contents + {
|
||||||
"focal": dockerfile_extra_contents_focal,
|
"focal": dockerfile_extra_contents_focal,
|
||||||
"bionic": dockerfile_extra_contents_bionic,
|
"bionic": dockerfile_extra_contents_bionic,
|
||||||
}[util.Interpolate("%(prop:os_codename)s")]
|
}[os_codename]
|
||||||
|
|
||||||
|
|
||||||
@util.renderer
|
|
||||||
def get_dockerfile_contents(props):
|
|
||||||
return _get_dockerfile_contents(props)
|
|
||||||
|
|
||||||
|
|
||||||
def trigger_child_hooks(buildbotUrl: str, os_codename: str, repository, branch, jobname, directory=".buildbot"):
|
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
|
# make a post request
|
||||||
request_data["properties"] = {
|
request_data["properties"] = {
|
||||||
"dockerfile": get_dockerfile_contents(
|
"dockerfile": _get_dockerfile_contents(
|
||||||
join(directory, job, "Dockerfile"), os_codename
|
join(directory, job, "Dockerfile"), os_codename
|
||||||
),
|
),
|
||||||
"build_script_available": is_build_script_available(build_script_exists),
|
"build_script_available": is_build_script_available(build_script_exists),
|
||||||
|
|
|
@ -17,22 +17,11 @@ import re
|
||||||
from buildbot.plugins import steps, util
|
from buildbot.plugins import steps, util
|
||||||
|
|
||||||
from .lib.renderers import *
|
from .lib.renderers import *
|
||||||
from .lib.worker_multibuild import trigger_child_hooks
|
|
||||||
|
|
||||||
|
addStep(steps.ShellCommand(
|
||||||
def list_jobs(directory=".buildbot"):
|
name="download worker",
|
||||||
"""
|
command=["sudo", "wget", "-O", "lib/worker_multibuild.py", "worker_multibuild.py"]
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
def find_artifacts(directory="out"):
|
def find_artifacts(directory="out"):
|
||||||
|
@ -45,6 +34,9 @@ def find_artifacts(directory="out"):
|
||||||
return join(directory, _)
|
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):
|
def add_parent_step(build_factory):
|
||||||
|
|
Loading…
Reference in New Issue