Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exception in get_results when build_number is specified #21

Open
chrisbainbridge opened this issue Jun 27, 2018 · 0 comments
Open

exception in get_results when build_number is specified #21

chrisbainbridge opened this issue Jun 27, 2018 · 0 comments

Comments

@chrisbainbridge
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant