Script Workflow "Condition" Function Not Working

Phillip Ponzer [Cprime]
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.
February 5, 2015

I have set up a transition's condition using a script workflow function slightly modified from the example given in the "Upgrading to 3.0" Script Runner wiki page:

import util.Bollo
import org.apache.log4j.Level
import org.apache.log4j.Logger
def log = Logger.getLogger("com.onresolve.jira.groovy")
log.setLevel(Level.DEBUG)
log.debug("Hello from the script")
Bollo.sayHello()
package util
import org.apache.log4j.Level
import org.apache.log4j.Logger
public class Bollo {
    public static Boolean sayHello() {
        def log = Logger.getLogger("com.onresolve.jira.groovy")
        log.setLevel(Level.DEBUG)
        log.debug("hello!")
        false
    }
}

I only have one condition for this transition and that is the scripted workflow function foo.groovy

However, when I go to the view issue page it allows me to take that transition (even though "sayHello" returns false).

What am I doing wrong?

Here's my log:

2015-02-05 15:53:22,112 http-bio-8081-exec-11 DEBUG <username> 953x16352x1 1pz8apa 10.30.184.65,127.0.0.1 /browse/TSF-2 [com.onresolve.jira.groovy] Hello from the script
2015-02-05 15:53:22,120 http-bio-8081-exec-11 DEBUG <username> 953x16352x1 1pz8apa 10.30.184.65,127.0.0.1 /browse/TSF-2 [com.onresolve.jira.groovy] hello!

3 answers

1 accepted

1 vote
Answer accepted
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.
February 5, 2015

Sorry, you don't return true or false from a condition, you set passesCondition to a boolean. In your example:

passesCondition = Bollo.sayHello()

Don't declare passesCondition, it comes in the script binding. I would prefer just returning true/false, but dealing with backwards compatibility is tricky.

Phillip Ponzer [Cprime]
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.
February 6, 2015

Thanks @Jamie Echlin [Adaptavist]! Helpful as always! :)

0 votes
Phillip Ponzer [Cprime]
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.
February 5, 2015

I added logging and my resulting log.

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.
February 5, 2015

Should work fine... anything in your logs? If not I'd bump up the logging as per the info here: https://jamieechlin.atlassian.net/wiki/display/GRV/getting%20help#GettingHelp-Supportrequests

Suggest an answer

Log in or Sign up to answer