Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,559,471
Community Members
 
Community Events
184
Community Groups

SriptRunner custom listener that sets status on epic to "Documenting" after all children are closed

Edited
helen levich
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.
Apr 23, 2019

After upgrade of Jira to 7/ScriptRunner to 5, existing ScriptRunner custom listener stopped working. Listener was setting status on parent epic to "Documenting" when status on all child objects were set to "Closed".

Script give two static errors and does not work in new version. 

Any suggestions will be greatly appreciate. 

Thank you 

 

import org.apache.log4j.Logger;
import com.atlassian.jira.component.ComponentAccessor
import org.apache.log4j.Category

import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.link.IssueLink;

//Issue Service
import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.issue.IssueInputParameters
import com.atlassian.jira.component.ComponentAccessor


// Logger
Logger log = Logger.getLogger("EPICLINK::");
// Set the logging level to INFO/DEBUG as needed
log.setLevel(org.apache.log4j.Level.DEBUG);
def logPrefix = "EPICLINK:: ";
logPrefix = logPrefix + event.issue.getKey() + ":: ";

log.debug(logPrefix)

try
{
log.debug(logPrefix + "TRY Block... START")
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();
CustomField epicLink = customFieldManager.getCustomFieldObjectByName('Epic Link');
Issue epic = event.issue.getCustomFieldValue(epicLink);

if(epic)
{
log.debug(logPrefix + "Epic Link Key:: " + epic.getKey())
def linkMgr = ComponentAccessor.getIssueLinkManager();
def blnNotClosed = false

for (IssueLink link in linkMgr.getOutwardLinks(epic.getId()))
{
if(link.getDestinationObject().getFixVersions().toArray()[0].getId() != epic.getFixVersions().toArray()[0].getId())
{
blnNotClosed = true;
break;

}
if(link.getDestinationObject().getStatus().getName() != "Closed")
{
blnNotClosed = true;
break;
}
}

if(!blnNotClosed)
{
log.warn("TRANSITION EPIC!!!!!!!")
IssueService issueService = ComponentAccessor.getIssueService();
IssueInputParameters issueInputParameters = issueService.newIssueInputParameters();

def loggedInUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();

IssueService.TransitionValidationResult transitionValidationResult = issueService.validateTransition(loggedInUser, epic.getId(), 821,issueInputParameters);
if (transitionValidationResult.isValid())
{

IssueService.IssueResult updateResult = issueService.transition(loggedInUser, transitionValidationResult);
if (!updateResult.isValid())
{
if (updateResult.getErrorCollection().hasAnyErrors())
{
int i = 1;
Iterator itr = updateResult.getErrorCollection().getErrors().entrySet().iterator();
while (itr.hasNext()) {
Map.Entry mapEntry = (Map.Entry) itr.next();
log.error(logPrefix + "transition FAIL issue: [err_msg_"+i+"]["+mapEntry.getKey() +"]["+ mapEntry.getValue()+"]")
i++;
}
}
}
else
{
log.debug(logPrefix + "transition Success...")
}
}
else
{
if (transitionValidationResult.getErrorCollection().hasAnyErrors())
{
int i = 1;
Iterator itr = transitionValidationResult.getErrorCollection().getErrors().entrySet().iterator();
while (itr.hasNext()) {
Map.Entry mapEntry = (Map.Entry) itr.next();
log.error(logPrefix + "transition FAIL issue: [err_msg_"+i+"]["+mapEntry.getKey() +"]["+ mapEntry.getValue()+"]")
i++;
}
}
}
}

}
log.debug(logPrefix + "TRY Block... END")
}

catch(Exception e)
{
log.error(e.getMessage())
}

image.png

Error on line 30

Issue epic = event.issue.getCustomFieldValue(epicLink);

image.pngError on line 40 

if(link.getDestinationObject().getFixVersions().toArray()[0].getId() != epic.getFixVersions().toArray()[0].getId())

image.png

 

1 answer

1 accepted

0 votes
Answer accepted
Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Apr 26, 2019

I generally ignore static type checking errors. These can help with debugging your code, but they don't automatically mean that your code is bad.

I would run it and look at the specific line that's failing by reviewing the logs.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events