in jbi/jira/service.py [0:0]
def add_jira_comments_for_changes(self, context: ActionContext):
"""Add comments on the specified Jira issue for each change of the event"""
bug = context.bug
event = context.event
issue_key = context.jira.issue
comments: list = []
user = event.user.login if event.user else "unknown"
for change in event.changes or []:
if change.field in ["status", "resolution"]:
comments.append(
{
"modified by": user,
"resolution": bug.resolution,
"status": bug.status,
}
)
if change.field in ["assigned_to", "assignee"]:
comments.append({"assignee": bug.assigned_to})
jira_response_comments = []
for i, comment in enumerate(comments):
logger.info(
"Create comment #%s on Jira issue %s",
i + 1,
issue_key,
extra=context.update(operation=Operation.COMMENT).model_dump(),
)
jira_response = self.client.issue_add_comment(
issue_key=issue_key, comment=json.dumps(comment, indent=4)
)
jira_response_comments.append(jira_response)
return jira_response_comments