Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

JQL Query using Java API?

Ramesh Lakshmanasamy July 2, 2018

I want use my JQL query in JAVA Api  using params

1 answer

3 votes
Mark Markov
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.
July 2, 2018

Hello @Ramesh Lakshmanasamy

You can do it like this

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.jql.parser.JqlQueryParser;
import com.atlassian.jira.issue.search.SearchProvider;
import com.atlassian.jira.web.bean.PagerFilter;

def findIssues(String jqlQuery) {
def issueManager = ComponentAccessor.issueManager
def user = ComponentAccessor.jiraAuthenticationContext.user
def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser.class)
def searchProvider = ComponentAccessor.getComponent(SearchProvider.class)

def query = jqlQueryParser.parseQuery(jqlQuery)
def results = searchProvider.search(query, user, PagerFilter.unlimitedFilter)
results.issues.collect
{ issue -> issueManager.getIssueObject(issue.id) }
}

def jqlQuery = "project = \"TEST\" and \"somecustomfield\" is not EMPTY"
def issues = findIssues(jqlQuery)
issues.each{it -> log.error("ISSUE KEY : " + it.getKey())
}
Swaroop Rao
Contributor
July 17, 2019

Is that Java?

Venugopal B V
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 1, 2019

This looks like groovy

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events