Abstract

This code snippet fetches all the last comments added on the issues linked to the current issue through a specific link type

Logic

Fetch the comments on the linked issues, linked to the current issue with a specific link type and add them to the current issue.

Snippet

def var = 1
def summ = ""
if (issue.getLinkedIssues("<Link type name>") && issue.getLinkedIssues("<Link type name>").first().get("comment").size() != 0){
  issue.getLinkedIssues("<Link type name>").first().get("comment").each{
   summ += "Comment " + var + ": " + it.getBody() +", created on " + it.getCreated().format("dd/MMMM/yyyy hh:mm a") + " by " + it.getAuthorFullName() + "\n"
    var = var + 1
 }
}
return summ

Placeholders

Placeholder

Description

Example

<Link type name>Name of the link typeis cloned by

Examples

The output of the code snippet is a String which you could use in a Groovy script, for example, to calculate and display the comments on the first issue linked to the current issue with the "is blocked by" link type.

def var = 1
def summ = ""
if (issue.getLinkedIssues("is blocked by") && issue.getLinkedIssues("is blocked by").first().get("comment").size() != 0){
  issue.getLinkedIssues("is blocked by").first().get("comment").each{
   summ += "Comment " + var + ": " + it.getBody() +", created on " + it.getCreated().format("dd/MMMM/yyyy hh:mm a") + " by " + it.getAuthorFullName() + "\n"
    var = var + 1
 }
}
return summ

References