Forums

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

How to get all issues in project , and how to get issues with status in progress script runner jql

Karim Belhadj
Contributor
December 14, 2018

Hello team

 

i would like to get all issues in one project and to compare the number with issues in the same project which has the status in progress. Thanks

2 answers

1 accepted

2 votes
Answer accepted
Gezim Shehu [Communardo]
Community Champion
December 14, 2018

Take a look at the script. I think this gets the job done for you.

In case you want to further process the issues, you can use the optional loop

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.search.SearchProvider
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.index.IssueIndexingService
import com.atlassian.jira.util.ImportUtils

def issueManager = ComponentAccessor.getIssueManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()


def sdUser = ComponentAccessor.getUserManager().getUserByKey('robot')
def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser)
def searchProvider = ComponentAccessor.getComponent(SearchProvider)
def query1 = jqlQueryParser.parseQuery("project = XYZ")
def query2 = jqlQueryParser.parseQuery("project = XYZ and status =\"In Progress\" ")
def results1 = searchProvider.search(query1, sdUser, PagerFilter.getUnlimitedFilter())
def results2 = searchProvider.search(query2, sdUser, PagerFilter.getUnlimitedFilter())

log.warn("All issues=" + results1.total)
log.warn("In Progress Issues=" + results2.total)
//if you want to do something with the issues, use the following loop
/*
results1.getIssues().each() {
    documentIssue ->
        def issue = issueManager.getIssueObject(documentIssue.id)
        //something goes here
}
*/
//x
0 votes
Karim Belhadj
Contributor
December 14, 2018

@Gezim Shehu [Communardo] , first of all thank you for your reponse , but ecxcuse i make my userByKey and project key , but always results = 0 for all issues and in progress.

Karim Belhadj
Contributor
December 14, 2018

 

def sdUser = ComponentAccessor.getUserManager().getUserByKey('Spectrum Admin')

log.warn("the user key is " + sdUser)

The user key is always null. 

Gezim Shehu [Communardo]
Community Champion
December 14, 2018

Are you using the username or display name of the user?

Usernames don't have spaces

Like # people like this
Karim Belhadj
Contributor
December 14, 2018

it works fine . I solve it . 

Gezim Shehu [Communardo]
Community Champion
December 14, 2018

Glad to help

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events