Fix exception in Gitlab trigger when project is not present

Fixes #1629
This commit is contained in:
Joseph Schorr 2016-07-26 15:18:43 -07:00
parent 9d48bcd0f1
commit 626042b10a

View file

@ -1,8 +1,6 @@
import logging
from functools import wraps
from urlparse import urljoin
from app import app, gitlab_trigger
from jsonschema import validate
@ -414,17 +412,18 @@ class GitLabBuildTrigger(BuildTriggerHandler):
if not payload:
raise SkipRequestException()
logger.debug('GitLab trigger payload %s', payload)
# Lookup the default branch.
default_branch = None
gl_client = self._get_authorized_client()
repo = gl_client.getproject(self.config['build_source'])
if repo is not False:
default_branch = repo['default_branch']
lookup_user = self.lookup_user
if repo is False:
logger.debug('Skipping GitLab build; project %s not found', self.config['build_source'])
raise SkipRequestException()
logger.debug('GitLab trigger payload %s', payload)
default_branch = repo['default_branch']
metadata = get_transformed_webhook_payload(payload, default_branch=default_branch,
lookup_user=lookup_user)
lookup_user=self.lookup_user)
prepared = self.prepare_build(metadata)
# Check if we should skip this build.