Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Get all JIRA comments to a scripted field.

Ash
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 4, 2019

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!!

1 answer

0 votes
Tuncay Senturk
Community Champion
February 4, 2019

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 

Ash
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 4, 2019

@Tuncay Senturk Thanks for your reply.

Sorry for the confusion. This is the same question i have,

https://community.atlassian.com/t5/Jira-questions/Jira-export-bulk-comments-with-Scripted-fields/qaq-p/218341

 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!!

Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 5, 2019

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.

Ash
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 5, 2019

@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!!

Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 5, 2019

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.

Suggest an answer

Log in or Sign up to answer