diff mbox series

[yocto-autobuilder2] builders: Improve the property fetching functionality

Message ID 20250926155310.26630-1-richard.purdie@linuxfoundation.org
State New
Headers show
Series [yocto-autobuilder2] builders: Improve the property fetching functionality | expand

Commit Message

Richard Purdie Sept. 26, 2025, 3:53 p.m. UTC
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>
---
 builders.py | 38 +++++++++++++++-----------------------
 1 file changed, 15 insertions(+), 23 deletions(-)
diff mbox series

Patch

diff --git a/builders.py b/builders.py
index d26b7e9d..7887945a 100644
--- a/builders.py
+++ b/builders.py
@@ -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))