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!

Posted by:.

5 replies on “How to add new custom JQL Function with ScriptRunner

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

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s