Add Comment to an Issue in a Post Function

automateworkflowuser

Overview

Configure a post function to add a comment to an issue when a workflow transition occurs.

Example

I work in support and when an issue transitions from 'open' to 'in progress', I want a comment to be automatically added to the ticket to let our client know we are working on their issue.

Good to Know

Specify issue values using the Groovy template syntax.

1 2 3 4 5 6 7 8 9 10 11 12 import com.atlassian.jira.component.ComponentAccessor // dispatch an event after creating the comment final boolean dispatchEvent = true // the body of the comment final String commentBody = """The text for your comment, which can include specific values from the issue, such as the specific issue assignee ${issue.assignee?.name ?: 'Unassigned'}""" // the author of the comment will be the logged in user def author = ComponentAccessor.jiraAuthenticationContext.loggedInUser ComponentAccessor.commentManager.create(issue, author, commentBody, dispatchEvent)