diff --git a/jenkinsapi/jenkinsbase.py b/jenkinsapi/jenkinsbase.py index 939f0d9a..0372f9bd 100644 --- a/jenkinsapi/jenkinsbase.py +++ b/jenkinsapi/jenkinsbase.py @@ -78,8 +78,8 @@ def get_data(self, url, params=None, tree=None): response = requester.get_url(url, params) if response.status_code != 200: - logger.error('Failed request at %s with params: %s %s', - url, params, tree if tree else '') + logger.error('Failed request at %s with params: %s %s - HTTP %s', + url, params, tree if tree else '', response.status_code) response.raise_for_status() try: return ast.literal_eval(response.text) diff --git a/jenkinsapi/queue.py b/jenkinsapi/queue.py index 1fe5c61d..58ab97dc 100644 --- a/jenkinsapi/queue.py +++ b/jenkinsapi/queue.py @@ -87,6 +87,8 @@ class QueueItem(JenkinsBase): """An individual item in the queue """ + MAX_RETRIES = 100 # if set, abort after this number of HTTPError + def __init__(self, baseurl, jenkins_obj): self.jenkins = jenkins_obj JenkinsBase.__init__(self, baseurl) @@ -142,6 +144,7 @@ def block_until_complete(self, delay=5): return build.block_until_complete(delay=delay) def block_until_building(self, delay=5): + retries = 0 while True: try: self.poll() @@ -150,7 +153,10 @@ def block_until_building(self, delay=5): time.sleep(delay) continue except HTTPError as http_error: + if self.MAX_RETRIES and retries >= self.MAX_RETRIES: + raise http_error log.debug(str(http_error)) + retries += 1 time.sleep(delay) continue