Script runner validator not working

Jon Starbird
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.
June 22, 2017

any ideas how to correct this:

/rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/runvalidator.json [c.o.jira.behaviours.GroovyScriptLoader] Class or file does not exist at this location

/rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/runvalidator.json [c.a.p.r.c.error.jersey.ThrowableExceptionMapper] Uncaught exception thrown by REST service: Class or file does not exist at this location
java.lang.Exception: Class or file does not exist at this location

This is the script it is occuring from:

import com.atlassian.jira.issue.Issue
import com.opensymphony.workflow.InvalidInputException
import com.atlassian.jira.component.ComponentAccessor

def cfm = ComponentAccessor.getCustomFieldManager()
Issue myIssue = issue

def verFixedField = cfm.getCustomFieldObject("customfield_19712") // Version Fixed field
def verifySteps
def steps

def selVer = myIssue.getCustomFieldValue(verFixedField)

if (myIssue.IssueType != 'Story' && myIssue.IssueType != 'Story-task') {

	verifySteps = cfm.getCustomFieldObject("customfield_19511") // Steps to Verify field
	steps = myIssue.getCustomFieldValue(verifySteps)
}

def rtrnResult = true
def verChk = false

if (selVer ==~  /^\[\d{1,3}\.\d{1,2}\.\d{1,2}\.\d{1,3}\]$/) {	
        verChk = true
}

if (myIssue.IssueType != 'Story' && myIssue.IssueType != 'Story-task') {
    if ((myIssue.getResolution() == "Fixed") && ((verChk == false) || (steps == null))) {
        rtrnResult = false
    }
} 
else
{
    if ((myIssue.getResolution() == "Fixed") && ((verChk == false))) {
        rtrnResult = false
    }	        
}

return rtrnResult

 

 

1 answer

0 votes
Thanos Batagiannis _Adaptavist_
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.
June 26, 2017

Hi J Starbird, 

When you say a worfklow validator you mean something like Validators right ?

The error message you get look like you are trying to do something with a Behaviour.

I can also see in your script 

// this will fail
myIssue.IssueType

//this is the right way
myIssue.issueType.name

Also a validator, when you want from it to fail, have to return 

throw new InvalidInputException("fixVersions", "Fix Version/s is required when specifying Resolution of 'Fixed'")

regards, Thanos

Jon Starbird
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.
June 26, 2017

Thank you. 

The error actually went away after I upgraded to the latest version of the plugin. 

I will make the changes you mentioned though.

 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events