Working with comments on issues
In this recipe, we will see how to manage commenting on issues using the JIRA API.
Let us have a look at all of the three major operations—creating, editing, and deleting comments. We will also have a look at how to restrict the comment visibility to a specific group of people or to a project role.
How to do it...
JIRA uses the CommentService
class to manage the comments on an issue.
Creating comments on issues
A comment can be added on to an issue as follows:
Comment comment = this.commentService.create(user, issue, commentString, false, new SimpleErrorCollection());
Here, commentString
is the comment we are adding, user is the user adding the comment, and issue
is the issue on which the comment is added. The fourth argument is a Boolean that determines whether an event should be dispatched or not. If it is true, an Issue Commented
event is thrown.
Creating comments on an issue and restricting it to a project role or group
If we need to restrict the visibility of...