I was able to come up with these two parts, but I'm having trouble linking them.
Part 1 - This accepts a filter which is listed as 'project = status = blocked'. This will list all issue codes that match the filter and separate them line by line. Is it necessary to convert the results into a list? I'm also wondering if it converts the entire result into one massive string or if each line is a string.
issues_in_project = jira.search_issues(
'project = status = Blocked'
)
issueList = list(issues_in_project)
search_results = '\n'.join(map(str, issueList))
print(search_results)
Part 2 - Right now, the jira.issue will only accept an issue code one at a time. I would like to use the list generated from Part 1 to keep running the code below for each and every issue code in the result. I'm having trouble linking these two parts.
issue = jira.issue(##Issue Code goes here##)
print(issue.fields.project.name)
print(issue.fields.summary + " - " + issue.fields.status.statusCategory.name)
print("Description: " + issue.fields.description)
print("Reporter: " + issue.fields.reporter.displayName)
print("Created on: " + issue.fields.created)
'project = status = Blocked'
is not a valid JQL. So first of all, you will not get a valid result from calling jira.search_issues('project = status = Blocked')
.
The result of jira.search_issues()
is basically a list
of jira.resources.Issue
objects and not a list
of string
or lines of string
. To be correct, I should say the result of jira.search_issues()
is of type jira.client.ResultList
, which is a subclass
of python's list
.
You already have all the required data in issues_in_project
if your JQL is correct. Therefore, you can loop through the list
and use the relevant information of each JIRA issue
. For your information, jira.issue()
returns exactly one jira.resources.Issue
object (if the issue key exists).
... # initialize jira
issues_in_project = jira.search_issues('status = Blocked')
for issue in issues_in_project:
print(issue.key)
print(issue.fields.summary)