Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

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

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
Community showcase
Published in Marketplace Apps & Integrations

Staying organized with Jira: best practices for a better project management

Project managers know this problem: A “mountain of work” lays in front of you, and you don’t know how and where to tackle them. Different to-dos lie ahead, but just one task after the other can be ha...

177 views 2 1
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you