From 0ba60b65dfa01ab32b11e14ff504cce5bebbf98e Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Sep 30 2016 15:07:24 +0000 Subject: Raise a specific error when no PR can be attached to a test run And do not notify the admins about this, test runs can happen for any reason, not necessarily because of a PR, so if pagure can't associate a run with a PR, so be it. --- diff --git a/pagure/api/ci/jenkins.py b/pagure/api/ci/jenkins.py index 92d10c2..6c2bb82 100644 --- a/pagure/api/ci/jenkins.py +++ b/pagure/api/ci/jenkins.py @@ -71,6 +71,9 @@ def jenkins_ci_notification( build_id, requestfolder=APP.config['REQUESTS_FOLDER'] ) + except pagure.exceptions.NoCorrespondingPR as err: + raise pagure.exceptions.APIError( + 400, error_code=APIERROR.ENOCODE, error=str(err)) except pagure.exceptions.PagureException as err: APP.logger.error('Error processing jenkins notification', exc_info=err) raise pagure.exceptions.APIError( diff --git a/pagure/exceptions.py b/pagure/exceptions.py index db3e7fa..8764baf 100644 --- a/pagure/exceptions.py +++ b/pagure/exceptions.py @@ -62,3 +62,9 @@ class GitConflictsException(PagureException): class HookInactiveException(PagureException): ''' Exception raised when the hook is inactive. ''' pass + + +class NoCorrespondingPR(PagureException): + ''' Exception raised when no pull-request is found with the given + information. ''' + pass diff --git a/pagure/lib/lib_ci.py b/pagure/lib/lib_ci.py index 33ddd98..4db97e1 100644 --- a/pagure/lib/lib_ci.py +++ b/pagure/lib/lib_ci.py @@ -46,7 +46,7 @@ def process_jenkins_build(session, project, build_id, requestfolder): continue if not pr_id: - raise pagure.exceptions.PagureException( + raise pagure.exceptions.NoCorrespondingPR( 'No corresponding PR found') if result not in BUILD_STATS: