2

我想与我的 JIRA 服务器通信。

我想使用 JIRA Client Framework 和JIRA Rest Client

final JerseyJiraRestClientFactory factory = new JerseyJiraRestClientFactory();
final URI jiraServerUri = new URI("https://issues.teamspace.local/jira");
final JiraRestClient restClient = factory.createWithBasicHttpAuthentication(jiraServerUri, "username", "password");

不幸的是,我不知道如何执行此操作,并且在网络上找不到任何有用的东西。

4

2 回答 2

0

在这里检查

https://ecosystem.atlassian.net/wiki/display/JRJC/Tutorial

public class Example1 {
    public static void main(String[] args) throws URISyntaxException {
        final JerseyJiraRestClientFactory factory = new JerseyJiraRestClientFactory();
        final URI jiraServerUri = new URI("http://localhost:8090/jira");
        final JiraRestClient restClient = factory.createWithBasicHttpAuthentication(jiraServerUri, "yourusername", "yourpassword");
        final NullProgressMonitor pm = new NullProgressMonitor();
        final Issue issue = restClient.getIssueClient().getIssue("TST-1", pm);

        System.out.println(issue);

        // now let's vote for it
        restClient.getIssueClient().vote(issue.getVotesUri(), pm);

        // now let's watch it
        restClient.getIssueClient().watch(issue.getWatchers().getSelf(), pm);

        // now let's start progress on this issue
        final Iterable<Transition> transitions = restClient.getIssueClient().getTransitions(issue.getTransitionsUri(), pm);
        final Transition startProgressTransition = getTransitionByName(transitions, "Start Progress");
        restClient.getIssueClient().transition(issue.getTransitionsUri(), new TransitionInput(startProgressTransition.getId()), pm);

        // and now let's resolve it as Incomplete
        final Transition resolveIssueTransition = getTransitionByName(transitions, "Resolve Issue");
        Collection<FieldInput> fieldInputs = Arrays.asList(new FieldInput("resolution", "Incomplete"));
        final TransitionInput transitionInput = new TransitionInput(resolveIssueTransition.getId(), fieldInputs, Comment.valueOf("My comment"));
        restClient.getIssueClient().transition(issue.getTransitionsUri(), transitionInput, pm);

    }

    private static Transition getTransitionByName(Iterable<Transition> transitions, String transitionName) {
        for (Transition transition : transitions) {
            if (transition.getName().equals(transitionName)) {
                return transition;
            }
        }
        return null;
    }

}
于 2014-09-23T08:16:33.090 回答
0

查看此处设置的依赖项

这就是您创建客户端的方式。

URI serverURI = new URL("url").toURI();
JiraRestClientFactory jiraFactory = new AsynchronousJiraRestClientFactory();
JiraRestClient client = jiraFactory.createWithBasicHttpAuthentication(serverURI,"username","password");

这是 API 的文档。

于 2016-06-27T19:22:27.750 回答