Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

ScriptRunner listener script fails for method call with "Unknown Source"

Boris Karl Schlein July 19, 2018

Hi,

I am working on a script which automatically sets and removes issue flags when blocking issue links are set. For me, the script looks good but I receive the following error message where the function/method call fails.

2018-07-19 10:36:08,685 INFO [runner.ScriptRunnerImpl]: EVENT: IssueLinkDeletedEvent
2018-07-19 10:36:08,803 ERROR [runner.AbstractScriptListener]: *************************************************************************************
2018-07-19 10:36:08,803 ERROR [runner.AbstractScriptListener]: Script function failed on event: com.atlassian.jira.event.issue.link.IssueLinkDeletedEvent, file: <inline script>
groovy.lang.MissingPropertyException: No such property: log for class: IssueModifier
	at IssueModifier.isAssignedToAllowedTeam(Script1314.groovy:118)
	at IssueModifier$isAssignedToAllowedTeam.call(Unknown Source)
	at Script1314.run(Script1314.groovy:293)

The code of the script looks like this.

class IssueModifier
{
...
public Boolean isAssignedToAllowedTeam(Issue issue)
{
String teamName = issue.getCustomFieldValue(this.customFieldTeam).toString();
if (this.allowedTeams.contains(teamName))
{
log.info issue.getKey() + ': team "' + teamName + '" is allowed team.';
return true;
}
log.info issue.getKey() + ': team "' + teamName + '" is not set as allowed team.';
return false;
}
...
}

...

if (event instanceof IssueLinkDeletedEvent)
{
log.info 'EVENT: IssueLinkDeletedEvent';

def issueLinkDeletedEvent = event as IssueLinkDeletedEvent;
def issueLink = issueLinkDeletedEvent.getIssueLink();
def sourceIssue = issueLink.getSourceObject() as Issue;

if (issueModifier.isAssignedToAllowedTeam(sourceIssue) && issueModifier.isAllowedIssueType(sourceIssue) && issueModifier.isOutwardBlockingLink(issueLink))
{
def destinationIssue = issueLink.getDestinationObject() as MutableIssue;

if (
!issueModifier.isAllowedIssueType(destinationIssue) &&
!issueModifier.isAssignedToAllowedTeam(destinationIssue) &&
// issueModifier.assignedToSameTeam(sourceIssue, destinationIssue) && // commented out because we accept the case to unflag an issue of anouter allowed team
!issueModifier.isFlagged(destinationIssue)
)
{
issueModifier.unflag(destinationIssue, event.getUser());
}
}
}

Best regards
Boris

1 answer

1 accepted

1 vote
Answer accepted
Alexey Matveev
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.
July 19, 2018

Hello,

You need to define the log variable

private static Logger log = Logger.getLogger(this.getName());

You code will be like this:

lass IssueModifier
{
private static Logger log = Logger.getLogger(this.getName());
...
public Boolean isAssignedToAllowedTeam(Issue issue)
{
String teamName = issue.getCustomFieldValue(this.customFieldTeam).toString();
if (this.allowedTeams.contains(teamName))
{
log.info issue.getKey() + ': team "' + teamName + '" is allowed team.';
return true;
}
log.info issue.getKey() + ': team "' + teamName + '" is not set as allowed team.';
return false;
}
...
}

...

if (event instanceof IssueLinkDeletedEvent)
{
log.info 'EVENT: IssueLinkDeletedEvent';

def issueLinkDeletedEvent = event as IssueLinkDeletedEvent;
def issueLink = issueLinkDeletedEvent.getIssueLink();
def sourceIssue = issueLink.getSourceObject() as Issue;

if (issueModifier.isAssignedToAllowedTeam(sourceIssue) && issueModifier.isAllowedIssueType(sourceIssue) && issueModifier.isOutwardBlockingLink(issueLink))
{
// now check if the destination issue can be flagged
def destinationIssue = issueLink.getDestinationObject() as MutableIssue;

if (
!issueModifier.isAllowedIssueType(destinationIssue) &&
!issueModifier.isAssignedToAllowedTeam(destinationIssue) &&
// issueModifier.assignedToSameTeam(sourceIssue, destinationIssue) && // commented out because we accept the case to unflag an issue of anouter allowed team
!issueModifier.isFlagged(destinationIssue)
)
{
issueModifier.unflag(destinationIssue, event.getUser());
}
}
}

Suggest an answer

Log in or Sign up to answer