Skip to content

Commit

Permalink
Merge pull request #3328 from s0undt3ch/master
Browse files Browse the repository at this point in the history
Include white-listed event payload properties for GitHub push events
  • Loading branch information
tardyp committed Jun 24, 2017
2 parents 8a73fd1 + 8bee6ad commit bee5416
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions master/buildbot/changes/github.py
Expand Up @@ -42,7 +42,7 @@


class PullRequestMixin(object):
def extractProperties(self, pr_info):
def extractProperties(self, payload):
def flatten(properties, base, info_dict):
for k, v in iteritems(info_dict):
name = ".".join([base, k])
Expand All @@ -53,7 +53,7 @@ def flatten(properties, base, info_dict):
properties[name] = v

properties = {}
flatten(properties, "github", pr_info)
flatten(properties, "github", payload)
return properties


Expand Down
@@ -0,0 +1 @@
The :py:class:`~buildbot.www.hooks.github.GitHubEventHandler` now allows the inclusion of white-listed properties for push events.
9 changes: 7 additions & 2 deletions master/buildbot/www/hooks/github.py
Expand Up @@ -119,8 +119,10 @@ def handle_push(self, payload, event):
# project = request.args.get('project', [''])[0]
project = payload['repository']['full_name']

# Inject some additional white-listed event payload properties
properties = self.extractProperties(payload)
changes = self._process_change(payload, user, repo, repo_url, project,
event)
event, properties)

log.msg("Received {} changes from github".format(len(changes)))

Expand Down Expand Up @@ -170,7 +172,8 @@ def handle_pull_request(self, payload, event):
len(changes), number))
return changes, 'git'

def _process_change(self, payload, user, repo, repo_url, project, event):
def _process_change(self, payload, user, repo, repo_url, project, event,
properties):
"""
Consumes the JSON as a python object and actually starts the build.
Expand Down Expand Up @@ -218,6 +221,8 @@ def _process_change(self, payload, user, repo, repo_url, project, event):
'event': event,
},
}
# Update with any white-listed github event properties
change['properties'].update(properties)

if callable(self._codebase):
change['codebase'] = self._codebase(payload)
Expand Down

0 comments on commit bee5416

Please sign in to comment.