Skip to content

Commit

Permalink
phase1: Implement custom step ShellCommandAndSetProperty
Browse files Browse the repository at this point in the history
Implement custom step ShellCommandAndSetProperty, as an extension of
ShellCommand with the addition of setting a bool property that is set
True or False if the shell command succeeded or not.

Signed-off-by: Christian Marangi <[email protected]>
  • Loading branch information
Ansuel committed Nov 13, 2024
1 parent d014e42 commit 7d7fb14
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions phase1/master.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ from buildbot import locks
from buildbot.data import resultspec
from buildbot.changes.gitpoller import GitPoller
from buildbot.config import BuilderConfig
from buildbot.process import buildstep
from buildbot.plugins import reporters
from buildbot.plugins import schedulers
from buildbot.plugins import steps
Expand Down Expand Up @@ -758,6 +759,37 @@ c["builders"].append(
)


# CUSTOM CLASS

# Extension of ShellCommand and sets in property:
# - True: the command succeded
# - False: the command failed
class ShellCommandAndSetProperty(buildstep.ShellMixin, buildstep.BuildStep):
name = "shellandsetproperty"
renderables = ['property']

def __init__(
self,
property=None,
**kwargs,
):
kwargs = self.setupShellMixin(kwargs)

self.property = property

super().__init__(**kwargs)

@defer.inlineCallbacks
def run(self):
cmd = yield self.makeRemoteShellCommand()

yield self.runCommand(cmd)

self.setProperty(self.property, not cmd.didFail(), "ShellCommandAndSetProperty Step")

return cmd.results()


# NB the phase1 build factory assumes workers are single-build only
def prepareFactory(target):
(target, subtarget) = target.split("/")
Expand Down

0 comments on commit 7d7fb14

Please sign in to comment.