I’m working with the python-jira library to extract worklog data from Jira Cloud. My script successfully pulls most worklog information but I’m stuck on getting the comment field from each worklog entry.
Here’s my current approach:
connection = JIRA(jira_url, basic_auth=(username, api_token))
# set up date range
from_date = datetime.date(2024, 3, 1)
to_date = datetime.date(2024, 3, 31)
# create query for filtering tickets
query = "project = ABC AND type in ('Bug', 'Task') AND status = Done AND resolved >= {} AND resolved <= {}".format(from_date, to_date)
# batch processing to get all tickets
offset = 0
page_size = 50
all_tickets = []
while True:
ticket_batch = connection.search_issues(jql_str=query, startAt=offset, maxResults=page_size, fields=['worklog', 'customfield_12345'])
if not ticket_batch:
break
all_tickets.extend(ticket_batch)
offset += page_size
for ticket in all_tickets:
ticket_details = connection.issue(ticket)
work_entries = ticket_details.fields.worklog.worklogs
for entry in work_entries:
print(f"Time: {entry.timeSpentSeconds}")
print(f"Author: {entry.author.displayName}")
print(f"Comment: {entry.comment}") # This line fails
When I try to access entry.comment
, I get an AttributeError saying the Worklog object doesn’t have a comment attribute. The documentation isn’t clear about how to properly access worklog comments. Has anyone figured out the right way to get these comments?