[users at bb.net] Custom build step

honas grael honasgraeymael at gmail.com
Sat Sep 28 06:22:57 UTC 2019


This looks useful to me Consider the class below, I want to run a query and
process the results returning success if some limit is true. Is this the
correct way to write a custom build step to do this?

class _GetDataFromVCS(steps.BuildStep):
    """
        Query VCS for data on the latest changes and process the output of
the query
        return success if there are more than 50 changes
    """

    def __init__(self, prop, **kwargs):
        steps.BuildStep.__init__(self, **kwargs)
        *#DO I need an __init__???*


    @defer.inlineCallbacks
    def run(self):
         # First query database for all peter's changes the output goes to
STDOUT
        _vcs_db=props.getProperty("database_name")
        _vcs_query="select * from _vcs_db where change_user=peter"
         result=_vcs_db.execute(_vcs_query)
         stdout.write(result)
           # Parse the query results that go to STDOUT see if there are
more than 50 changes
          for line in STDOUT:
            line_count=line_count+1
          if line_count>50:
              yield defer.returnValue(SUCCESS)
          else:
              yield defer.returnValue(FAIL)

How do I make use of the class in my master.cfg file? to create an instance
of the _GetDataFromVCS do I just do

vcs_step = _GetDataFromVCS(description=step, descriptionDone=step,
 name=step, haltOnFailure=True)
            f.addStep(vcs_step)

I don't have a "COMMAND" anywhere in my class, will this work?

On Thu, Sep 26, 2019 at 2:43 PM Clément Hurlin <clement.hurlin at provenrun.com>
wrote:

> Dear Viraj,
>
> What do you want to do with your custom step ?
>
> Shooting in the dark, here are simple custom steps I have in my bots, to
> provide you examples:
>
> class _ClearPropertyStep(steps.BuildStep):
>     """
>         Step that clears a property
>     """
>
>     def __init__(self, prop, **kwargs):
>         steps.BuildStep.__init__(self, **kwargs)
>         assert prop is not None and len(prop) > 0
>         self.property = prop
>
>     @defer.inlineCallbacks
>     def run(self):
>         print("Clearing property " + self.property)
>         self.setProperty(self.property, None, str(type(self)))
>         yield defer.returnValue(SUCCESS)
>
> Here's another one:
>
> class _URLStep(steps.BuildStep):
>     """
>         Step whose only purpose is to show a description and an URL
>     """
>
>     renderables = steps.BuildStep.renderables + [
>         'url_text',
>         'url',
>     ]
>
>     def __init__(self, url_text, url, **kwargs):
>         steps.BuildStep.__init__(self, **kwargs)
>         assert url_text is not None
>         self.url_text = url_text
>         assert url is not None
>         self.url = url
>
>     @defer.inlineCallbacks
>     def run(self):
>         print("Setting URL: " + str(self.url))
>         self.addURL(self.url_text, self.url)
>         yield defer.returnValue(SUCCESS)
>
> Best,
>
> Clément Hurlin
>
> Hi
>
> I got stuck in buildbot for configuring custom buildbot step.
>
> Can you please help me with one of the example how we can create custom
> build step.
>
> Regards,
> Viraj Wadate
>
> _______________________________________________
> users mailing listusers at buildbot.nethttps://lists.buildbot.net/mailman/listinfo/users
>
> _______________________________________________
> users mailing list
> users at buildbot.net
> https://lists.buildbot.net/mailman/listinfo/users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.buildbot.net/pipermail/users/attachments/20190928/009a3aaf/attachment.html>


More information about the users mailing list