Skip to content

exception in get_results when build_number is specified #21

Description

@chrisbainbridge

When the result query includes a build number, the server returns response type "resultDetails" (not "restResults" as returned by /result) which is singular but code expects a response containing 'results', resulting in:

>>> list(bamboo.get_results(key, '32'))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "bamboo_api/api.py", line 372, in get_results
    results = response['results']

Fix may be something like:

diff --git a/bamboo_api/api.py b/bamboo_api/api.py
index 6deaf7b..01add81 100644
--- a/bamboo_api/api.py
+++ b/bamboo_api/api.py
@@ -369,6 +369,10 @@ class BambooAPIClient(object):
         while qs['start-index'] < size:
             # Get page, update page size and yield branches
             response = self._get_response(url, qs).json()
+            # querying a build_number returns only one response
+            if 'results' not in response:
+                yield response
+                return
             results = response['results']
             size = results['size']
             for r in results['result']:

Or just a new method get_result() to return the single object.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions