Workflow validator not executed

I am running Jira 6.3.3 and the latest Version of Script Runner. I am trying to run a custom validation script on a workflow but it seems not be executed as nothing happens and there are no entries in the log file, even if the script contains syntax errors. I have also tried running the example validator from the website, with the same result. Any suggestions what could be the problem or where to look for further information?

22 answers

Could you provide your code so we check more in details?

0 vote

Make sure the workflow is published, and associated with the project/issue type you are testing with.

@KostasTo narrow it down I reduced the code to a bare minimum. My aim was to see if it runs, by having a validator that always fails. I tried a simple

false

which seemed to have worked for older versions and the example from the documentation

import org.apache.log4j.Category
import com.opensymphony.workflow.InvalidInputException
 
log = Category.getInstance("com.onresolve.jira.groovy.example.testValidator")
log.debug("Condition testValidator script running")
 
invalidInputException = new InvalidInputException("Validation failure")

Neither the validation fail nor the log message is shown.

@JamieI double checked it with a collegue.

The following script

import org.apache.log4j.Category
import com.opensymphony.workflow.InvalidInputException
 
log = Category.getInstance("com.onresolve.jira.groovy.example.testValidator")
log.debug("Condition testValidator script running")
 
invalidInputException = new InvalidInputException("Validation failure")

is executed for me. I got the log and transition was not executed.

Are u sure that you have followed the steps in order to have the custom script validator executed?

In order to make it work you have to:

  1. Create a file with the above code
  2. Add it to a directory of your server
  3. Add the file path to your workflow

Hope that helps

Could you provide full information how do you add this condition to a workflow?

0 vote

Could just add a screenshot. It really depends if you are using "custom validator" or "simple scripted validator". They work differently. "false" is fine for the latter. For the former, try finishing your script with:

throw new InvalidInputException("Validation failure")

what version of SR are you using?

I am using a Custom Validator and SR version 3.0.4

I am using an absolut path to the script file and tried to run it as inline script as well. Running it from a file I just noticed this message in the log:

/secure/CommentAssignIssue.jspa [onresolve.scriptrunner.runner.ScriptRunnerImpl] Add a script root for this path: /path/to/my/file/script.groovy

Do you have any suggestions how to resolve this?

Are you sure you published your workflow? Just making sure ....

@RaduYes I am.

... and you are on the correct issue type, if WF was not published for all issue types ... ?

And workflow scheme with proper workflow attached to project

0 vote

Does using:

throw new InvalidInputException("Validation failure")

work?

Yes it is.

Yes it is. I am using a default workflow in an out of the box Jira with Script Runner.

Yes, "throw" works for me. (I have the same problems as Robert)

import org.apache.log4j.Category
import com.opensymphony.workflow.InvalidInputException
  
log = Category.getInstance("com.onresolve.jira.groovy.example.testValidator")
log.debug("Condition testValidator script running")
  
throw new InvalidInputException("Validation failure")
0 vote

What version of the plugin are you using? I think I may have broken that backwards compatibility in one of the most recent releases.

Blame it on the developer, right.

@jamie I use Jira 6.3.4 and Script Runner 3.0.4.

Okay. Turns out, I tested the throws variant only from a file not as an inline script, which works file.

Thank you for your help.

I am still curious what to do about the log message, if I try to run a custom script from a file:

/secure/CommentAssignIssue.jspa [onresolve.scriptrunner.runner.ScriptRunnerImpl] Add a script root for this path: /path/to/my/file/script.groovy

0 vote

"throw new InvalidInputException" works fine for me fron file and inline script. In 3.0.5:

invalidInputException = new InvalidInputException

will also work (from both).

0 vote

@Radu... it could be any member of the massive development team. But when I found out who, they'll be sorry....

99 little bugs in the code

99 little bugs in the code

Take one down, patch it around

117 little bugs in the code

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Amir Kazemi
Posted 5 hours ago in Jira

We want to know what Jira Service Desk apps you're using!

Hi Community! My name is Amir and I’m on the Jira Service Desk product marketing team at Atlassian. Our team would love to understand how you’re leveraging our ecosystem for Jira Service Desk. Wha...

22 views 0 4
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you