Skip to content

Commit

Permalink
Fix Gitlab comment reporter when MR not found (#1197)
Browse files Browse the repository at this point in the history
  • Loading branch information
nvuillam authored Jan 24, 2022
1 parent 65bac7c commit bca7374
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions megalinter/reporters/GitlabCommentReporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,13 @@ def produce_report(self):
gitlab_server_url, job_token=config.get("CI_JOB_TOKEN")
)
project = gl.projects.get(gitlab_project_id)
mr = project.mergerequests.get(gitlab_merge_request_id)
if mr is None:
logging.info(
"[Gitlab Comment Reporter] No merge request has been found, so no comment has been posted"
try:
mr = project.mergerequests.get(gitlab_merge_request_id)
except gitlab.GitlabGetError as e:
logging.warning(
"[Gitlab Comment Reporter] No merge request has been found with "
f"id {gitlab_merge_request_id}, so no comment has been posted\n"
+ str(e)
)
return

Expand Down

0 comments on commit bca7374

Please sign in to comment.