@com.adaptavist.hapi.cloud.analytics.CloudTracked abstract class AbstractCommentableIssueDelegate<T, V> extends AbstractIssuesDelegate<T, V>
| Constructor and description |
|---|
AbstractCommentableIssueDelegate(Issue originalIssue) |
| Type Params | Return Type | Name and description |
|---|---|---|
|
void |
setComment(java.lang.String comment)Adds a comment to the issue |
|
void |
setComment(java.util.Map comment)Adds a comment to the issue using Atlassian Document Format (ADF). |
Adds a comment to the issue Issues.getByKey('Test').update { setComment("This will be a new comment on the issue") }
Adds a comment to the issue using Atlassian Document Format (ADF).
This method allows you to set a comment in an issue using ADF, which provides rich text formatting capabilities beyond basic Markdown. ADF supports advanced features such as tables, panels, and more complex styling options.
Note: This method expects a Map representation of ADF. If you have a JSON string, you can parse it into a Map using Groovy's JsonSlurper before passing it to this method.
Usage Examples:
1. Simple paragraph with bold text:
Issues.getByKey("JRA-10").update {
setComment([
version: 1,
type: "doc",
content: [
[
type: "paragraph",
content: [
[type: "text", text: "This is "],
[type: "text", text: "bold", marks: [[type: "strong"]]],
[type: "text", text: " text in ADF."]
]
]
]
])
}
2. Bullet list:
Issues.get("JRA-10").update {
setComment([
version: 1,
type: "doc",
content: [
[
type: "bulletList",
content: [
[type: "listItem", content: [[type: "paragraph", content: [[type: "text", text: "Item 1"]]]]],
[type: "listItem", content: [[type: "paragraph", content: [[type: "text", text: "Item 2"]]]]]
]
]
]
])
}
3. Table with two columns:
Issues.getByKey("JRA-10").update {
setComment([
version: 1,
type: "doc",
content: [
[
type: "table",
attrs: [isNumberColumnEnabled: false, layout: "default"],
content: [
[
type: "tableRow",
content: [
[type: "tableHeader", content: [[type: "paragraph", content: [[type: "text", text: "Header 1"]]]]],
[type: "tableHeader", content: [[type: "paragraph", content: [[type: "text", text: "Header 2"]]]]]
]
],
[
type: "tableRow",
content: [
[type: "tableCell", content: [[type: "paragraph", content: [[type: "text", text: "Cell 1"]]]]],
[type: "tableCell", content: [[type: "paragraph", content: [[type: "text", text: "Cell 2"]]]]]
]
]
]
]
]
])
}
4. Using JsonSlurper to parse a JSON string:
import groovy.json.JsonSlurper
def jsonString = '''
{
"version": 1,
"type": "doc",
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "This is a paragraph parsed from JSON."
]
}
]
}
'''
Issues.getByKey("JRA-10").update {
def jsonSlurper = new JsonSlurper()
def adfMap = jsonSlurper.parseText(jsonString)
setComment(adfMap)
}
}
For more information on ADF structure and capabilities, refer to the Atlassian Developer documentation: ADF Structure
While ADF provides more formatting options than Markdown, it's also more complex to construct manually. Consider using the string-based setDescription method for simpler formatting needs.
comment - a Map representing the ADF structure for the comment being added to the issue