Workflow validator not executed

Robert Krause
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.
August 17, 2014

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

0 votes
Alexey_Rjeutski__Polontech_
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.
August 21, 2014

99 little bugs in the code

99 little bugs in the code

Take one down, patch it around

117 little bugs in the code

0 votes
Radu Dumitriu
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.
August 21, 2014

@Jamie- be merciful :)

http://9gag.com/gag/ad604MN

0 votes
JamieA
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.
August 21, 2014

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

0 votes
JamieA
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.
August 21, 2014

"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 votes
Robert Krause
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.
August 20, 2014

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 votes
Manuel Kummerländer August 20, 2014

@jamie I use Jira 6.3.4 and Script Runner 3.0.4.

0 votes
Radu Dumitriu
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.
August 19, 2014

Blame it on the developer, right.

0 votes
JamieA
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.
August 19, 2014

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

0 votes
Manuel Kummerländer August 19, 2014

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 votes
Robert Krause
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.
August 19, 2014

Yes it is.

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

0 votes
JamieA
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.
August 19, 2014

Does using:

throw new InvalidInputException("Validation failure")

work?

0 votes
Alexey_Rjeutski__Polontech_
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.
August 19, 2014

And workflow scheme with proper workflow attached to project

0 votes
Radu Dumitriu
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.
August 19, 2014

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

0 votes
Robert Krause
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.
August 19, 2014

@RaduYes I am.

0 votes
Radu Dumitriu
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.
August 19, 2014

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

0 votes
Robert Krause
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.
August 18, 2014

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?

0 votes
JamieA
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.
August 18, 2014

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?

0 votes
Alexey_Rjeutski__Polontech_
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.
August 18, 2014

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

0 votes
Tsol
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.
August 18, 2014

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

0 votes
Robert Krause
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.
August 18, 2014

@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.

0 votes
JamieA
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.
August 17, 2014

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

0 votes
Tsol
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.
August 17, 2014

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

Suggest an answer

Log in or Sign up to answer