December 15, 2022

ScriptRunner: Create Comment or Write Text Field with Links

I didn't find any documentation for this one.
I wanted in a ScriptRunner listener to document the action done by the listener with a comment in the impacted issue, with a link in the comment pointing to the user documentation.

You can do this easily by formatting links with [linktext|linkurl]

Here is an example of code for a comment:

commentBody = "[Listener|https://confluenceroot/pages/viewpage.action?pageId=375883539] labelled the issue with 'suspect_mod' because parent issue ${issue.key} had following fields changed while in Status 'Closed':" + commentBody

// flag current issue
def issueManager = ComponentAccessor.getIssueManager()
def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def commentManager = ComponentAccessor.getCommentManager()


// Add a comment to issue
commentManager.create(issue, user, commentBody, true)

No comments:

Post a Comment