JIRA Rest客户端SSL认证

时间:2014-07-24 05:51:22

标签: ssl jira jira-rest-api jira-rest-java-api

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

我想使用JIRA客户端框架和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");

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

2 个答案:

答案 0 :(得分: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;
    }

}

答案 1 :(得分:0)

查看依赖关系设置here

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

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

Here's the documentation for the API.