jira

Using the Jira Client API

Get Issues From a JQL Query

final AsynchronousJiraRestClientFactory factory = new AsynchronousJiraRestClientFactory();
restClient = factory.createWithBasicHttpAuthentication(URI.create(JIRA_SERVER), JIRA_LOGIN, JIRA_PASSWORD);
getFilteredIssues("project = TestProject");

public Iterable<Issue> getFilteredIssues(String filterJql) throws Exception {
    final SearchRestClient searchClient = this.connection.getRestClient().getSearchClient();
    HashSet<String> fields = Sets.newHashSet("*all");

    int total = Integer.MAX_VALUE;
    final ArrayList<Issue> issuesList = new ArrayList<>();
    while(issuesList.size() < total){
        Promise<SearchResult> promiseResult = searchClient.searchJql(filterJql, 50, issuesList.size(), fields);
        final SearchResult issues = promiseResult.get();
        issuesList.addAll((Collection<? extends Issue>) issues.getIssues());
    
        if (total == Integer.MAX_VALUE) {
            total = issues.getTotal();
        }
    }        
    
    return issuesList;
    
}

This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow