summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlvaro Echeverria <alvaromania@gmail.com>2015-09-18 13:05:28 -0300
committerAlvaro Echeverria <alvaromania@gmail.com>2015-09-18 13:05:28 -0300
commit60ca5b8105d072e10144c7dee73b9b9d88ede2d1 (patch)
tree09fcf60a466f2ec453c8fbde185bcf2f20c166a6
parent529367bb88718e1fcfb07d3a864777649a6ac23a (diff)
downloadGit-Auto-Deploy-60ca5b8105d072e10144c7dee73b9b9d88ede2d1.zip
Git-Auto-Deploy-60ca5b8105d072e10144c7dee73b9b9d88ede2d1.tar.gz
Git-Auto-Deploy-60ca5b8105d072e10144c7dee73b9b9d88ede2d1.tar.bz2
Improving Gitlab CI support
-rwxr-xr-xGitAutoDeploy.py18
1 files changed, 8 insertions, 10 deletions
diff --git a/GitAutoDeploy.py b/GitAutoDeploy.py
index a5d308b..1e14f2c 100755
--- a/GitAutoDeploy.py
+++ b/GitAutoDeploy.py
@@ -65,7 +65,7 @@ class GitWrapper():
print 'Updating ' + repo_config['path']
cmd = 'cd "' + repo_config['path'] + '"' \
- '&& unset GIT_DIR ' + \
+ '&& unset GIT_DIR ' + \
'&& git fetch origin ' + \
'&& git reset --hard origin/' + branch + ' ' + \
'&& git submodule init ' + \
@@ -134,7 +134,6 @@ class WebhookRequestHandler(BaseHTTPRequestHandler):
to collect and compare them all."""
import json
- gitlab_push_data = False
content_type = self.headers.getheader('content-type')
length = int(self.headers.getheader('content-length'))
body = self.rfile.read(length)
@@ -151,8 +150,6 @@ class WebhookRequestHandler(BaseHTTPRequestHandler):
if not 'push_data' in data:
print "ERROR - Unable to recognize data format"
return repo_urls
- else:
- gitlab_push_data = True
# Assume GitLab if the X-Gitlab-Event HTTP header is set
if gitlab_event:
@@ -201,17 +198,18 @@ class WebhookRequestHandler(BaseHTTPRequestHandler):
if k in data['repository']:
repo_urls.append(data['repository'][k])
- #Special Case for Gitlab CI
+ # Special Case for Gitlab CI
elif content_type == "application/json" and "build_status" in data:
print "Received event from Gitlab CI"
- for k in ['url', 'git_http_url', 'git_ssh_url']:
- if data['build_status'] == "success":
+ # Only add repositories if the build is successful. Ignore it in other case.
+ if data['build_status'] == "success":
+ for k in ['url', 'git_http_url', 'git_ssh_url']:
if k in data['push_data']['repository']:
repo_urls.append(data['push_data']['repository'][k])
- else:
- print "Gitlab CI build '%d' has status '%s'. Not pull will be done" % (data['build_id'], data['build_status'])
- break
+ else:
+ print "Gitlab CI build '%d' has status '%s'. Not pull will be done" % (
+ data['build_id'], data['build_status'])
else:
print "ERROR - Unable to recognize request origin. Don't know how to handle the request. Outdated GitLab?"