...
Code Block | ||
---|---|---|
| ||
import com.atlassian.jira.issue.IssueManager; import com.atlassian.jira.issue.MutableIssue; import com.atlassian.jira.component.ComponentAccessor; import com.atlassian.jira.issue.link.IssueLink; import com.atlassian.jira.issue.comments.CommentManager; import com.atlassian.jira.user.ApplicationUser; CommentManager commentMgr = ComponentAccessor.getCommentManager() ApplicationUser currentUser = ComponentAccessor.getJiraAuthenticationContext().loggedInUser IssueManager im = ComponentAccessor.getIssueManager(); MutableIssue issue = im.getIssueObject("SP-5519"); def lastComment = commentMgr.getComments(issue).last().body //def links = ComponentAccessor.getIssueLinkManager().getInwardLinks(issue.getId()) def links = ComponentAccessor.getIssueLinkManager().getOutwardLinks(issue.getId()) //return links[0].getSourceObject() def output = "" for( l in links) { //use this for Outward links output = output + l.issueLinkType.name + ": " + l.getDestinationObject() + "<br/>" //use this for Inward links //output = output + l.issueLinkType.name + ": " + l.getSourceObject() + "<br/>" // adding comment for the main issue commentMgr.create(l.getSourceObject(),currentUser, "Test------------", false) // adding comment for the linked issue commentMgr.create(l.getDestinationObject(),currentUser, "Test------------", false) } return output |
10. Getting all Sub-Tasks and Issue Key of the Sub-Task (Server)
Code Block |
---|
//import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.component.ComponentAccessor;
IssueManager im = ComponentAccessor.getIssueManager();
MutableIssue issue = im.getIssueObject("ANDROID-38");
def output = ""
for (e in issue.getSubTaskObjects()) {
output = output + e.getSummary() +"," + e.issueType.name + "<br/>"
}
return output
// Uncomment this line for getting issue key of the subtask
//MutableIssue sub_issue = im.getIssueObject(issue.getSubTaskObjects()[0].toString());
//return sub_issue |
Learning:
Knowledge on how script-runner listener works for both cloud and server
Got to understand different scenarios for Jira based on which scripts were written
Basic knowledge on groovy
While setting the value for multi-select system fields always set the values based on “id’s of values” and not “values itself“ in behaviors
While setting the value for single select system fields we can directly give “values” instead of “id’s of values”
script-runner behaviors
While setting the value for single select custom field we have to give “id’s of values” only (can also be directly configured in field setting as these are custom fields)
...