Work with Comments
With HAPI, you can easily add comments to existing work items. This page walks you through adding comments using HAPI’s Issues.addComment function.
Pattern for adding comments with HAPI
When you add a comment with HAPI, you can follow this basic pattern:
- Import
Issuesfrom@scriptrunnerhq/hapi/issues. - Call
Issues.addCommentinside your script's defaultasyncfunction. - Provide the work item key and a comment body (supports markdown‑style formatting).
The following example shows this general pattern:
typescriptimport * as Issues from '@scriptrunnerhq/hapi/issues' export default async function () { await Issues.addComment('WORKITEM_KEY', { body: 'my comment with **markdown**', }) }
You can use the same Issues.addComment pattern to add any plain‑text or markdown‑formatted comment to a work item.
Markdown to ADF conversion
HAPI accepts Markdown for rich-text fields such as comments and descriptions, and automatically converts it to Atlassian Document Format (ADF), the format Jira stores. We recommend you use plain Markdown when building out your comments. For example:
typescriptawait Issues.addComment('JRA-1', { body: 'Deployed **v2.1** — see the runbook.' }).
In-app script example scripts
The following example is available in‑app:
- Add a comment to a work item: Shows how to use
Issues.addCommentwith a work item key and a markdown‑formattedbodyto add a comment to an existing work item.