Custom JQL - problem JqlQueryFunction Edited

Hi,

I'm struggling with your your simplest example of the custom JQL i found on gist.

package com.onresolve.jira.groovy.jql

import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.jql.query.QueryCreationContext
import com.atlassian.jira.util.MessageSet
import com.atlassian.query.clause.TerminalClause
import com.atlassian.query.operand.FunctionOperand
import org.apache.lucene.search.Query

class ABC extends AbstractScriptedJqlFunction implements JqlQueryFunction{
@Override
String getDescription() {
"gets issues with ABC in the summary"
}

@Override
List<Map> getArguments() {
[
[
"description": "Subquery",
"optional": false,
]
]
}

@Override
String getFunctionName() {
"abcFunction"
}

@Override
Query getQuery(QueryCreationContext queryCreationContext, FunctionOperand operand, TerminalClause terminalClause) {

}
}

actually I even had to remove method 

 def String subquery
@Override
MessageSet validate(User user, FunctionOperand operand, TerminalClause terminalClause) {
}

because it was throwing an execption. The page with existing functions got populated properly.

2018-01-09 09:07:14,565 http-nio-8080-exec-11 WARN za577 547x1411314x2 176k4ob 10.131.6.59,10.139.54.244 /rest/plugins/1.0/com.onresolve.jira.groovy.groovyrunner-key [c.o.scriptrunner.runner.ScriptRunnerImpl] Script /var/atlassian/application-data/jira/scripts/com/onresolve/jira/groovy/jql/abc.groovy failed to load/compile: startup failed: /var/atlassian/application-data/jira/scripts/com/onresolve/jira/groovy/jql/abc.groovy: 32: Method 'validate' from class 'com.onresolve.jira.groovy.jql.ABC' does not override method from its superclass or interfaces but is annotated with @Override. @ line 32, column 5. @Override ^ 1 error

 

Afer then after I re-scan the scripts I get ugly error and the page with function failed to load.


I am running Server instance of JIRA v7.3.1 with Script Runner 5.0.14.
Any help appreciated, I spend on it hours with no success. I also need to unable the addon and enable back to correctly scan the new version. 

Many thanks,
Jaroslav

1 answer

1 vote

Have you tried the example from our documentation here? That works for me. It's unlikely the one in the gist works as that is a much older example.

From the error it looks like your putting the file in the correct place. Note you may want to rename your file to uppercase ABC.groovy so it matches the class name.

If that doesn't work then you may want to try upgrading ScriptRunner to a later version. I can't think of any bugs that are in 5.0.14 though that would cause this.

Many thanks @Adam Markham [Adaptavist]

renaming the file to match the class name did the trick. I can see now function in the list of functions. Thanks

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published May 30, 2018 in Marketplace Apps

Three tips for boosting your board's efficiency with Story Maps

Trello is one of the most effective tools for driving your sprints. It's customizable for every Agile team and product owners and Scrum masters (SM) love it. However, Agile teams often struggle with:...

835 views 2 9
Read article

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