3

I am working on a tool for Jira using the python-jira library.

def find_ticket_key_by_name(search_string):
    global jira
    result = jira.search_issues('project=FSA and status != Done  and summary ~ "HOST TESTER-APP:SERVICE1-SERVICECOUNT" order by createdDate', maxResults=1)
    return result

The function above successfully returns a jira object

[<JIRA Issue: key=u'FSA-11', id=u'119060'>]

however if I attempt to print the key value

result.key

I get this error

AttributeError: 'ResultList' object has no attribute 'key'

3 Answers 3

2

I found the problem and posting solution in case somebody gets stuck like me.

In my case I am only returning one result and I assumed it will return one object.

This is not the case as indicated by the "ResultList" error. Even if you return 1 result the function will still return a list with 1 result.

Sign up to request clarification or add additional context in comments.

Comments

0

What you are getting is a List in python, so try the following:-

  • result[0].key to get the key value
  • result[0].id to get id value.

You can always check type any data using type keyword, in your case it will be class 'jira.client.ResultList' which is a List object

Comments

0

If you want to get the key of issue you searched,

if result:
  for issue in result:
    print(issue.key)

It should help.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.