Hi All,
I'm trying pull all JIRA comments to a scripted field using scriptrunner.
I'm able to pull all comments but they are not in a sequence. How can we break each comment by author name?
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.comments.Comment
import com.atlassian.jira.issue.comments.CommentManager
import com.atlassian.jira.component.ComponentAccessor
def commentManager = ComponentAccessor.getCommentManager()
def comment = commentManager.getComments (issue)
return (comment?.authorFullName + comment?.body)
TIA!!
Hello Ash,
Sorry, if I misunderstood your question. Here are some clues that may be helpful.
You can also use below methods:
- particular user's comments for an issue
commentManager.getCommentsForUser(issue, user)
- particular user's comments for an issue after a date
commentManager.getCommentsForUserSince(issue, user, since)
Here are all methods of CommentManager
@Tuncay Senturk _Snapbytes_ Thanks for your reply.
Sorry for the confusion. This is the same question i have,
As mentioned by Nic this is what able to get so far,
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.comments.Comment
import com.atlassian.jira.issue.comments.CommentManager
import com.atlassian.jira.component.ComponentAccessor
def commentManager = ComponentAccessor.getCommentManager()
def comment = commentManager.getComments (issue)
def results
each $item in $comment{
item.getUpdateAuthorFullName() ->results
item.getUpdated() -> results
item.getBody() -> results
}
TIA!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The code I gave there is just to drag the raw information out, it doesn't try to format it.
You'll want to add line or paragraph breaks to $item to format it better. I would expect it to come out in date order though, if it does not, then you'll need to add a sort to the "each" part.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Nic Brough -Adaptavist- Thanks fro your reply.
Can you please help me with that line. I tried difference ways and filled up my tmp size.
TIA!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ah, that would suggest you have too many comments to fit inside a simple block of text. You'll need to define a bigger type of variable.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.