首先建立springboot工程,使用maven进行构建,pom依赖以下:html
<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进行后续的操做。java
public JiraRestClient loginJira(){ AsynchronousJiraRestClientFactory asynchronousJiraRestClientFactory = new AsynchronousJiraRestClientFactory(); JiraRestClient jiraRestClient = asynchronousJiraRestClientFactory.createWithBasicHttpAuthentication(URI.create(jira地址), 用户名,密码); return jiraRestClient; }
经过查看接口能够看到能够获取到多种操做类型的client。web
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信息spring
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能够进行的操做上边已经已经注释。springboot
原文出处:https://www.cnblogs.com/javasingle/p/12213783.htmlasync