scripts/ci/gitlab-pipeline-status: give more information on failures

When an HTTP GET request fails, it's useful to go beyond the "not
successful" message, and show the code returned by the server.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
Message-Id: <20210222193240.921250-3-crosa@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
This commit is contained in:
Cleber Rosa 2021-02-22 14:32:39 -05:00 committed by Thomas Huth
parent 2faf56bd95
commit 861d1d509b
1 changed files with 3 additions and 1 deletions

View File

@ -56,7 +56,9 @@ def get_json_http_response(url):
connection.request('GET', url=url) connection.request('GET', url=url)
response = connection.getresponse() response = connection.getresponse()
if response.code != http.HTTPStatus.OK: if response.code != http.HTTPStatus.OK:
raise CommunicationFailure("Failed to receive a successful response") msg = "Received unsuccessful response: %s (%s)" % (response.code,
response.reason)
raise CommunicationFailure(msg)
return json.loads(response.read()) return json.loads(response.read())