Search code examples
buildbot

How to compute a value from the src::branch property when definition a build step


I must compute a value for a build step based on the src::branch property and based on the available documentation this only seems to be possible by defining custom renderables.

I created a custom renderable defined as follows:

@implementer(IRenderable)
class DetermineVersion(object):
    def getRenderingFor(self, props):
        if props.hasProperty("src::branch"):
            return "--version=" + props['src::branch'].lower().replace("tag/", "")
        else:
            raise Exception("The property 'branch' (tag/version) must be set")

and used it as follows in a build step:

    f.addStep(steps.ShellCommand(
        name="create_tag",
        command=["python", "createTag.py", DetermineVersion()],
    ))

Unfortunately this does not seem to work as expected and regardless of the fact of the "branch" property is set or not, I always see the exception thrown by my getRenderingFor function.


Solution

  • I used wrong property name src::branch instead of branch:

    This works as expected:

    @implementer(IRenderable)
    class DetermineVersion(object):
        def getRenderingFor(self, props):
            if props.hasProperty("branch"):
                return "--version=" + props['branch'].lower().replace("tag/", "")
            else:
                raise Exception("The property 'branch' (tag/version) must be set")