1

My goal is to setup a buildbot that listens out for webhooks from a github server and then builds the repo listed in the webhook via a generic make all command.

The issue I'm having is that it appears in the build steps I need to specify the github repo in advance i.e.

factory.addStep(
    steps.GitHub(
        repourl= "github.<domain>.com/<user>/<repo>/", 
        mode='full',
        method='clobber'        
   )
)

Where as ideally I'd want to be able to grab the repo url from the http request (obviously validating it before blindly running code) and then check it out. Something like:

factory.addStep(
    steps.GitHub(
        repourl= request["repo_url"], 
        mode='full',
        method='clobber'        
   )
)

Is this possible in the buildbot framework? Any tips or additional documentation to look at would be greatly appreciated!!

gowerc
  • 1,039
  • 9
  • 18
  • Maybe something like these would fit: http://docs.buildbot.net/current/manual/configuration/buildsteps.html#setproperties-step AND/OR http://docs.buildbot.net/current/manual/configuration/buildfactories.html#dynamic-build-factories – jmunsch Mar 26 '19 at 18:07
  • This seems along the right lines but I can't work out how to get details of the original webhook into the build properties object – gowerc Mar 26 '19 at 18:54
  • Check out the handle pull request method: https://github.com/buildbot/buildbot-contrib/blob/master/master/contrib/github_buildbot.py – jmunsch Mar 26 '19 at 22:26

1 Answers1

0

Just encase anyone else comes across this I found two potential solutions. First there is an undocumented option in the webhook which allows to add all of the HTTP request information into the properties object:

'www' : { 
    ...
    "change_hook_dialects" : {'github': {"github_property_whitelist": "*"}},
    ...
}

This then gives you access to all the http request info in the scheduler / builder stages. You can then also grab property information in the build_steps stage using the util properties i.e.

factory.addStep(
    steps.GitHub(
        repourl= util.Property('repository'), 
        mode='full',
        method='clobber', 
        submodules=True
    )
)
gowerc
  • 1,039
  • 9
  • 18