summaryrefslogtreecommitdiffstats
path: root/GitAutoDeploy.py
diff options
context:
space:
mode:
authorETL <etlweather@keylimebox.org>2016-03-11 20:07:47 -0500
committerETL <etlweather@keylimebox.org>2016-03-11 20:07:47 -0500
commitbbb12196a0939bc31a5688e3ea77c03996be2a11 (patch)
treec51db243eaaa6603154dcdb4856bd01cb3885072 /GitAutoDeploy.py
parent61289b58d2a0e61e7c3b8502c1bb45a3daac2014 (diff)
downloadGit-Auto-Deploy-bbb12196a0939bc31a5688e3ea77c03996be2a11.zip
Git-Auto-Deploy-bbb12196a0939bc31a5688e3ea77c03996be2a11.tar.gz
Git-Auto-Deploy-bbb12196a0939bc31a5688e3ea77c03996be2a11.tar.bz2
Adds event filtering support for GitLab and documentation.
Filtering is now possible with GitLab events using the action and ref values. Documentation for the configuration file also added. Fixes #74 and relates to #43
Diffstat (limited to 'GitAutoDeploy.py')
-rwxr-xr-xGitAutoDeploy.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/GitAutoDeploy.py b/GitAutoDeploy.py
index 7deddac..8827ca0 100755
--- a/GitAutoDeploy.py
+++ b/GitAutoDeploy.py
@@ -228,6 +228,14 @@ class WebhookRequestHandler(BaseHTTPRequestHandler):
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']
+
# Assume GitHub if the X-GitHub-Event HTTP header is set
elif github_event:
@@ -311,6 +319,7 @@ class WebhookRequestHandler(BaseHTTPRequestHandler):
else:
logger.error("ERROR - Unable to recognize request origin. Don't know how to handle the request.")
+ logger.info("Event details - ref: %s; action: %s" % (ref or "master", action))
return repo_urls, ref or "master", action
@@ -405,13 +414,15 @@ class GitAutoDeploy(object):
# 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 'type' in filter and filter['type'] == 'pull-request-filter':
if filter['ref'] == ref and filter['action'] == action:
continue
raise FilterMatchError()
else:
- logger.error('Unrecognized filter: ' % filter)
- raise FilterMatchError()
+ if 'action' in filter and filter['action'] != action:
+ raise FilterMatchError()
+ if 'ref' in filter and filter['ref'] != ref:
+ raise FilterMatchError()
except FilterMatchError as e:
continue