I have a project built around publishing. Each Epic will require the same steps (cover, blurb, tag-line, etc.), so I am already automatically generating an Issue with these subtasks. For example:
Book 1 (Epic)
Format this book (issue)
pdf version (subtask)
mobi version (subtask)
epub version (subtask)
The problem is that once multiple books are in the project, that's going to be a lot of issues/subtasks with identical names. In order to fix this, I'm writing a script to add the title (in this case, "book 1"), to the summaries of the corresponding issue / subtasks. So, the end result should look like this:
Book 1 (Epic)
Format this book: Book 1 (issue)
pdf version: Book 1 (subtask)
mobi version: Book 1 (subtask)
epub version: Book 1 (subtask)
I'm close, but the "setSummary()" command at the end of this script isn't running, despite my successfully logging the necessary id's and summaries to make sure they're there.
I'm current running this code as a Post-Function: Any thoughts?
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.issue.link.IssueLink;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.link.IssueLink;
if(issue.issueType.name == 'Epic'){
// Get Target Epic
IssueManager im = ComponentAccessor.getIssueManager();
def issueSummary = issue.getSummary();
def projectTitle = issueSummary.minus("Publish ");
String results = "";
def valid = false;
def output = "";
// Filter through all the Epic's related issues / subtasks
List<IssueLink> allOutIssueLink = ComponentAccessor.getIssueLinkManager().getOutwardLinks(issue.getId());
for (Iterator<IssueLink> outIterator = allOutIssueLink.iterator(); outIterator.hasNext();) {
IssueLink issueLink = (IssueLink) outIterator.next();
// Create the new issue / subtask string (NewString)
def linkedIssue = issueLink.getDestinationObject();
String type = linkedIssue.getIssueType().getName();
String NewString = type + ": " + projectTitle;
// Assign the new string to that issue / sub-task's title (CurrentIssueId)
def CurrentIssueId = linkedIssue.getId();
MutableIssue CurrentTask = im.getIssueObject(CurrentIssueId);
// HOW TO APPLY THE NEW SUMMARY TO THE DB?!
MutableIssue TempIssue = im.getIssueObject(CurrentIssueId);
TempIssue.setSummary(NewString);
}
}