diff options
Diffstat (limited to 'gitautodeploy')
-rw-r--r-- | gitautodeploy/httpserver.py | 35 | ||||
-rw-r--r-- | gitautodeploy/parsers/gitlab.py | 8 |
2 files changed, 38 insertions, 5 deletions
diff --git a/gitautodeploy/httpserver.py b/gitautodeploy/httpserver.py index a0ae4c5..1e0c198 100644 --- a/gitautodeploy/httpserver.py +++ b/gitautodeploy/httpserver.py @@ -39,6 +39,8 @@ class WebhookRequestHandler(BaseHTTPRequestHandler): # Could be GitHubParser, GitLabParser or other repo_configs, ref, action = ServiceRequestParser(self._config).get_repo_params_from_request(request_headers, request_body) + logger.info("Event details - ref: %s; action: %s" % (ref or "master", action)) + #if success: # print "Successfullt handled request using %s" % ServiceHandler.__name__ #else: @@ -126,14 +128,37 @@ class WebhookRequestHandler(BaseHTTPRequestHandler): # Verify that all filters matches the request if specified if 'filters' in repo_config: for filter in repo_config['filters']: - if filter['type'] == 'pull-request-filter': - if filter['ref'] == ref and filter['action'] == action: + + # Filter with both action and ref? + if 'action' in filter and 'ref' in filter: + + if filter['action'] == action and filter['ref'] == ref: + # This filter is a match, OK to proceed continue + raise FilterMatchError() - else: - logger.error('Unrecognized filter: ' % filter) + + # Filter with only action? + if 'action' in filter: + + if filter['action'] == action: + # This filter is a match, OK to proceed + continue + raise FilterMatchError() - + + # Filter with only ref? + if 'ref' in filter: + + if filter['ref'] == ref: + # This filter is a match, OK to proceed + continue + + raise FilterMatchError() + + # Filter does not match, do not process this repo config + raise FilterMatchError() + except FilterMatchError as e: continue diff --git a/gitautodeploy/parsers/gitlab.py b/gitautodeploy/parsers/gitlab.py index 6ebdb6f..580fed2 100644 --- a/gitautodeploy/parsers/gitlab.py +++ b/gitautodeploy/parsers/gitlab.py @@ -26,6 +26,14 @@ class GitLabRequestParser(WebhookRequestParser): if k in data['repository']: repo_urls.append(data['repository'][k]) + # extract the branch + if 'ref' in data: + ref = data['ref'] + + # set the action + if 'object_kind' in data: + action = data['object_kind'] + # Get a list of configured repositories that matches the incoming web hook reqeust repo_configs = self.get_matching_repo_configs(repo_urls) |