Forums

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

How to get all issues by project category and Custom Label field in jira using Groovy script?

Peddinti Hemanth Satyakumar September 27, 2018

Hi, I'm totally new to Groovy. I'm trying to fetch issues based on

1)Project category and 2)Custom Label field.

 

Could anyone help me with this where to start?

 

 

1 answer

0 votes
Elifcan Cakmak
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.
September 27, 2018

Hello,

You can use jql statements on your scripts. Such as:

def appuser = authenticationContext.getLoggedInUser()

jqlSearch = "category = test and labels = test"

def issues = null

SearchService.ParseResult parseResult = searchService.parseQuery(appuser, jqlSearch)
if (parseResult.isValid()) {
def searchResult = searchService.search(appuser, parseResult.getQuery(), PagerFilter.getUnlimitedFilter())
issues = searchResult.issues.collect {issueManager.getIssueObject(it.id)}
} else {
log.error("Invalid JQL: " + jqlSearch);
}

After that you can iterate through issues like this:

for (int i = 0; i < issues.size(); i++) {
def issue = issues[i]
... your code here ...
}

You need to import necessary classes, of course. 

Hope this helps.

Regards,

Suggest an answer

Log in or Sign up to answer