diff --git a/endpoints/trigger.py b/endpoints/trigger.py index 26aa2c1e4..a68b49869 100644 --- a/endpoints/trigger.py +++ b/endpoints/trigger.py @@ -1264,7 +1264,7 @@ class GitLabBuildTrigger(BuildTriggerHandler): return None - def _prepare_build(self, commit, ref, is_manual): + def _prepare_build(self, commit_sha, ref, is_manual): config = self.config gl_client = self._get_authorized_client() @@ -1272,6 +1272,10 @@ class GitLabBuildTrigger(BuildTriggerHandler): if repo is False: raise TriggerStartException('Could not find repository') + commit = gl_client.getrepositorycommit(repo['id'], commit_sha) + if repo is False: + raise TriggerStartException('Could not find repository') + try: [committer] = gl_client.getusers(search=commit['committer_email']) except ValueError: @@ -1335,7 +1339,7 @@ class GitLabBuildTrigger(BuildTriggerHandler): ref = payload['ref'] raise_if_skipped(self.config, ref) - return self._prepare_build(commit, ref, False) + return self._prepare_build(commit['id'], ref, False) def manual_start(self, run_parameters=None): run_parameters = run_parameters or {} @@ -1360,7 +1364,7 @@ class GitLabBuildTrigger(BuildTriggerHandler): ref = 'refs/heads/%s' % branch_name - return self._prepare_build(commit, ref, True) + return self._prepare_build(commit['id'], ref, True) def get_repository_url(self): gl_client = self._get_authorized_client()