java 调用jira_java中通过JIRA REST Java Client 使用jira
首先創建springboot工程,使用maven進行構建,pom依賴如下:
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-starter
org.springframework.boot
spring-boot-starter-test
test
com.atlassian.jira
jira-rest-java-client-core
5.1.6
io.atlassian.fugue
fugue
4.7.2
provided
加入依賴以后可以通過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_java中通过JIRA REST Java Client 使用jira的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: pyquery获取不到网页完整源代码_爬
- 下一篇: 计算机网络课程设计之网络聊天程序的设计与