首页 > 编程语言 > 详细

java中通过JIRA REST Java Client 使用jira

时间:2020-03-11 11:41:38      阅读:109      评论:0      收藏:0      [点我收藏+]

首先创建springboot工程,使用maven进行构建,pom依赖如下:

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
<!-- 使用jira-rest-cilent的依赖--> <dependency> <groupId>com.atlassian.jira</groupId> <artifactId>jira-rest-java-client-core</artifactId> <version>5.1.6</version> </dependency> <dependency> <groupId>io.atlassian.fugue</groupId> <artifactId>fugue</artifactId> <version>4.7.2</version> <scope>provided</scope> </dependency> </dependencies>

  加入依赖以后可以通过asynchronousJiraRestClientFactory进行登陆获取认证,本次使用用户名密码的方式进行校验,也可以使用其他 的方式进行校验(例如token的方式),登陆验证以后获取到jiraRestClient进行后续的操作。

    public JiraRestClient loginJira(){
        AsynchronousJiraRestClientFactory asynchronousJiraRestClientFactory = new AsynchronousJiraRestClientFactory();
        JiraRestClient jiraRestClient = asynchronousJiraRestClientFactory.createWithBasicHttpAuthentication(URI.create(jira地址), 用户名,密码);
        return jiraRestClient;
    }

  通过查看接口可以看到可以获取到多种操作类型的client。

public interface JiraRestClient extends Closeable {
    IssueRestClient getIssueClient(); //可以进行issue相关的操作

    SessionRestClient getSessionClient();

    UserRestClient getUserClient(); //jira用户相关的操作

    GroupRestClient getGroupClient();

    ProjectRestClient getProjectClient(); //工程相关的操作

    ComponentRestClient getComponentClient();

    MetadataRestClient getMetadataClient();

    SearchRestClient getSearchClient();

    VersionRestClient getVersionRestClient();

    ProjectRolesRestClient getProjectRolesRestClient();

    AuditRestClient getAuditRestClient();

    MyPermissionsRestClient getMyPermissionsRestClient();

    void close() throws IOException;
}

  简单示例获取对应的issue信息

 Issue issue = jiraRestClient.getIssueClient().getIssue(此处是需要查询的issuekey).claim();
        System.out.println(issue);
        System.out.println(issue.getStatus()+"+++++++++++++++++");
        System.out.println(issue.getStatus().getName()+"jira status ");

  其他的操作都是获取对应的client进行操作即可,对应client可以进行的操作上边已经已经注释。

java中通过JIRA REST Java Client 使用jira

原文:https://www.cnblogs.com/javasingle/p/12213783.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!