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
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
Bridget Sauer
Published Thursday in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

365 views 0 6
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