5

我正在尝试获取项目的所有问题,然后找到已完成的问题,但我不知道如何。
我将用户连接到 Jira,而不是想了解他的所有项目和所有问题。然后我想找出其中的哪些问题已经完成。有人可以帮我吗?

我有这个:

Iterable <BasicProject> allProj;
this.yourUsername = userName;
this.yourPassword = password;

this.jiraServerUri = new URI("https://applifting.atlassian.net");
this.factory = new JerseyJiraRestClientFactory();;
this.restClient = factory.createWithBasicHttpAuthentication(jiraServerUri, yourUsername, yourPassword);
final NullProgressMonitor pm = new NullProgressMonitor();
allProj = this.restClient.getProjectClient().getAllProjects(pm);

for(Iterator<BasicProject> i = allProj.iterator(); i.hasNext(); ) {
    BasicProject proj = i.next();
    Project ActualProject = this.restClient.getProjectClient().getProject(proj.getKey(), pm);
    ComponentRestClient cm =

}

我认为在这个for周期中,当我拥有所有项目时,我应该解决所有问题。

4

1 回答 1

14

如果您有一个指定搜索条件的 JQL,您可以调用它:https ://docs.atlassian.com/jira/REST/latest/#d2e2716

有关代码示例,请查看此处:https ://answers.atlassian.com/questions/192961/answers/4049301

一个工作示例:(也在这里: http: //pastebin.com/WUMZ0vZa

package com.example.jirasandbox;

import com.atlassian.jira.rest.client.api.JiraRestClient;
import com.atlassian.jira.rest.client.api.JiraRestClientFactory;
import com.atlassian.jira.rest.client.api.domain.BasicProject;
import com.atlassian.jira.rest.client.api.domain.Issue;
import com.atlassian.jira.rest.client.api.domain.SearchResult;
import com.atlassian.jira.rest.client.api.domain.User;
import com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory;
import com.atlassian.util.concurrent.Promise;
import java.net.URI;

public class CustomJiraRestClient {

    private static final String JIRA_URL = "http://jira-dev:8080";
    private static final String JIRA_ADMIN_USERNAME = "admin";
    private static final String JIRA_ADMIN_PASSWORD = "admin";

    public static void main(String[] args) throws Exception {
        // Construct the JRJC client
        System.out.println(String.format("Logging in to %s with username '%s' and password '%s'", JIRA_URL, JIRA_ADMIN_USERNAME, JIRA_ADMIN_PASSWORD));
        JiraRestClientFactory factory = new AsynchronousJiraRestClientFactory();
        URI uri = new URI(JIRA_URL);
        JiraRestClient client = factory.createWithBasicHttpAuthentication(uri, JIRA_ADMIN_USERNAME, JIRA_ADMIN_PASSWORD);

        // Invoke the JRJC Client
        Promise<User> promise = client.getUserClient().getUser("admin");
        User user = promise.claim();

        for (BasicProject project : client.getProjectClient().getAllProjects().claim()) {
            System.out.println(project.getKey() + ": " + project.getName());
        }

        Promise<SearchResult> searchJqlPromise = client.getSearchClient().searchJql("project = MYPURRJECT AND status in (Closed, Completed, Resolved) ORDER BY assignee, resolutiondate");

        for (Issue issue : searchJqlPromise.claim().getIssues()) {
            System.out.println(issue.getSummary());
        }

        // Print the result
        System.out.println(String.format("Your admin user's email address is: %s\r\n", user.getEmailAddress()));

        // Done
        System.out.println("Example complete. Now exiting.");
        System.exit(0);
    }
}
于 2015-03-23T10:17:28.527 回答