builders: Improve the property fetching functionality

Rather than running specific commands on the builds, call a function in helper
and read back the json properties in a generic way. This allows us to adapt the
commands for the new layout from bitbake-setup.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Richard Purdie 2025-09-26 16:52:21 +01:00
parent 49b6f636a3
commit 1d913d9a24

View File

@ -96,6 +96,11 @@ def canStartBuild(builder, wfb, request):
wfb.worker.exitQuarantine()
return True
def extract_json_props(rc, stdout, stderr):
if rc != 0 or stderr:
return {}
return json.loads(stdout)
def create_builder_factory():
f = util.BuildFactory()
@ -127,18 +132,11 @@ def create_builder_factory():
haltOnFailure=True,
name="Unpack shared repositories"))
f.addStep(steps.SetPropertyFromCommand(command=util.Interpolate("cd %(prop:builddir)s/build; git rev-parse HEAD"),
property="yp_build_revision",
doStepIf=util.Property("yp_build_revision", default='') == '',
haltOnFailure=True,
name='Set build revision'))
f.addStep(steps.SetPropertyFromCommand(command=util.Interpolate("cd %(prop:builddir)s/build; git rev-parse --abbrev-ref HEAD"),
property="yp_build_branch",
doStepIf=util.Property("yp_build_branch", default='') == '',
haltOnFailure=True,
name='Set build branch'))
f.addStep(steps.SetPropertyFromCommand(
command=util.Interpolate("%(prop:builddir)s/yocto-autobuilder-helper/scripts/getproperties.py %(prop:builddir)s/build"),
extract_fn=extract_json_props,
name='Load build revisions',
haltOnFailure=True))
f.addStep(RunConfigCheckSteps(posttrigger=False))
@ -330,17 +328,11 @@ def create_parent_builder_factory(buildername, waitname):
haltOnFailure=True,
name="Unpack shared repositories"))
factory.addStep(steps.SetPropertyFromCommand(command=util.Interpolate("cd %(prop:builddir)s/build; git rev-parse HEAD"),
property="yp_build_revision",
doStepIf=util.Property("yp_build_revision", default='') == '',
haltOnFailure=True,
name='Set build revision'))
factory.addStep(steps.SetPropertyFromCommand(command=util.Interpolate("cd %(prop:builddir)s/build; git rev-parse --abbrev-ref HEAD"),
property="yp_build_branch",
doStepIf=util.Property("yp_build_branch", default='') == '',
haltOnFailure=True,
name='Set build branch'))
factory.addStep(steps.SetPropertyFromCommand(
command=util.Interpolate("%(prop:builddir)s/yocto-autobuilder-helper/scripts/getproperties.py %(prop:builddir)s/build"),
extract_fn=extract_json_props,
name='Load build revisions',
haltOnFailure=True))
# run-config
factory.addStep(RunConfigCheckSteps(posttrigger=False))