On {JIRA_GOME}/scripts/ create this folders:
For example: ../jira_home/scripts/com/onresolve/jira/groovy/jql
Then add the groovy file with the new JQLFunction, exmaple: ABC.groovy
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" } def String subquery @Override MessageSet validate(User user, FunctionOperand operand, TerminalClause terminalClause) { } @Override Query getQuery(QueryCreationContext queryCreationContext, FunctionOperand operand, TerminalClause terminalClause) { } }
Then Go to Addons –> ScriptRunner –> Script JQL Functions –> and then press “Scan”
That’s all!
Hi, do you know if it’s possible to do a Rest inside a Jql Custom function ?
with HTTPBuilder for example
LikeLike
why not?
Probably you can use the same classes in Groovy like the REST Endpoints.
See Custom JQL Function (Scriptrunner): https://scriptrunner.adaptavist.com/4.3.3/jira/custom-jql-functions.html
And see REST Endpoints (Scriptrunner): https://scriptrunner.adaptavist.com/4.3.3/jira/rest-endpoints.html
Or these classes (Scriptrunner):
https://jirasupport.wordpress.com/2016/05/23/groovy-rest-ws-call-example-to-tempo-jira-plugin/
Otherwise (Java) you can follow these instructions to create the JQL function: https://developer.atlassian.com/jiradev/jira-platform/guides/search/tutorial-adding-a-jql-function-to-jira
And import the JAVA rest classes.
Best regards
LikeLike
I just copied this code placed under com.onresolve.jira.groovy.jql .
Clicked on Scan but it didnt recognise the functio
LikeLike
Hi Vineela,
You must create these folders inside your jira_home:
/jira_home/scripts/com/onresolve/jira/groovy/jql
Then place here the file with the script.
Try with this JQL function script ( that is compatible with JIRA 7.x)
https://mraddon.blog/2017/01/11/toprows-jql-function-for-jira-7-2-scriptrunner/
Best regards!
LikeLike