I have written a simple python script to query jira …
from jira import JIRA
jiraurl = "https://myjira.com"
username = "un"
password = "pw"
class MyJira:
def __init__(self, server_url, username, password):
self.jira = JIRA(server_url, basic_auth=(username. password))
def query(self, jql):
issues = self.jira.search_issues(jql)
return issues
jira_query = MyJira(jiraurl, username, password)
issues = jira_query.query(jql_query)
print(issues)
my_list = []
for issue in issues:
print(issue)
my_list.append(issue)
print(my_list)
here is the output of print(issues):
[<JIRA Issue: key='PBI-12345', id='1375672'>,<JIRA Issue: key='PBI-12346', id='1375872>,<JIRA Issue: key='PBI-12349', id='1376672>]
here is the output of print(issue)
PBI-12345
PBI-12346
PBI-12349
and here is the output of print(my_list)
[<JIRA Issue: key='PBI-12345', id='1375672'>,<JIRA Issue: key='PBI-12346', id='1375872>,<JIRA Issue: key='PBI-12349', id='1376672>]
when i did the first print(issues);
is my output a dictionary ?
with the following objects:
<JIRA Issue: key=‘PBI-12345’, id=‘1375672’>,
<JIRA Issue: key=‘PBI-12346’, id='1375872>,
<JIRA Issue: key=‘PBI-12349’, id='1376672>
when i give my 2nd print statement print(issue):
should it not be printing the objects ? why is it printing just the ticket number like so
PBI-12345
PBI-12346
PBI-12349
when i’m printing my 3rd print statement: here is what i’m expecting
[‘PBI-12345’, ‘PBI-12346’, ‘PBI-12349’]
but why is it printing this output?
[<JIRA Issue: key=‘PBI-12345’, id=‘1375672’>,<JIRA Issue: key=‘PBI-12346’, id='1375872>,<JIRA Issue: key=‘PBI-12349’, id='1376672>]
I have also tried using my_list.append(issue["key"])
but i get a TypeError:‘Issue’ object is not subscriptable