Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

...

...

...

...

...

...

...

...

...

Abstract

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

Logic

...

  • Iterate over each linked issue linked to the current issue

...

  • through the specified link type
  • Fetch the last comment on each linked issue and

...

  • store in a variable

Snippet

Code Block
languagegroovy
linenumberstrue
def var = 1
def summ = ""
if (issue.getLinkedIssues("<Link type name>") &&==null)
return null;
issue.getLinkedIssues("<Link type name>").first()each{
  if(it.get("comment").size(){
!= 0){   issue.getLinkedIssues("<Link type name>").first().comm = it.get("comment").each{last()
    summ += "Comment on " + varit.key + ": " + itcomm.getBody() +", created on " + itcomm.getCreated().format("dd/MMMM/yyyy hh:mm a") + " by " + itcomm.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 cloned by" link type.

Code Block
languagegroovy
linenumberstrue
def var = 1
def summ = ""
if (issue.getLinkedIssues("is blockedcloned by")==null)
return &&null;
issue.getLinkedIssues("is blockedcloned by").first()each{
  if(it.get("comment").size(){
!= 0){   issue.getLinkedIssues("is blocked by").first()comm = it.get("comment").each{last()
    summ += "Comment on " + varit.key + ": " + itcomm.getBody() +", created on " + itcomm.getCreated().format("dd/MMMM/yyyy hh:mm a") + " by " + itcomm.getAuthorFullName() + "\n"
    var = var + 1  }
}
return summ

References