Search code examples
buildbot

How to pass variables to Buildbot?


I'm using Buildbot V.0.9.0rc3

My Buildbot triggers when I send a change via command line or if I receieve an http Post request to the correct address.

Currently I'm sending changes to Buildbot in two different ways:

$ buildbot sendchange -m localhost:9999 -a example-user:pass -W me -C default

or

curl -X POST -d author=aalvz -d comments=mycomment -d project=my_project -d category=default -d repository=some http://192.168.33.20:8020/change_hook/base

My schedulers are defined like this:

c['schedulers'].append(schedulers.SingleBranchScheduler(
                             name="waiter",
                             builderNames=["runtests"],
                             change_filter=util.ChangeFilter(category='default')))
c['www'] = dict(port=8020,
                plugins=dict(waterfall_view={}, console_view={}),
                change_hook_dialects={
                                      'base': True,
                                      'somehook': {'option1':True,
                                                   'option2':False}})

And my Step in factory cloning a repo looks like this:

factory.addStep(steps.Git(repourl='git@github.com:AAlvz/my_repo.git', mode='full', workdir='newFolder', branch='my_branch', submodules=True, clobberOnFailure=True))

I would like to receive a POST with some data and use that data to trigger different commands. Something like: (using $ to make the variables noticeable)

factory.addStep(steps.Git(repourl=$myjson.name, mode='full', workdir=$myjson.path, branch=$myjson.branch, submodules=True, clobberOnFailure=True))

That way I could send a JSON like:

{myjson: {name: github/myrepo.git, path: /tmp/my/path, branch: my_branch}}

and be able to clone the repository provided by the JSON.

Thanks in advance! I hope the question is clear enough. I can provide with logs or any needed configuration. Thanks!


Solution

  • This is solved Using Buildbot Properties.

    You cand send them via command line (with PBChangeSource) using the flag

    buildbot sendchange ... --properties=my_property:myvalue
    

    The flag can be used multiple timpes if multiple properties are needed.