BAEL-1139 How to Integration with the JIRA API (#2665)
* BAEL-1139 How to Integration with the JIRA API * BAEL-1139 How to Integration with the JIRA API * BAEL-1139 How to Integration with the JIRA API
This commit is contained in:
parent
8ed5c8e293
commit
8db94607f9
|
@ -569,12 +569,22 @@
|
|||
<groupId>javax.cache</groupId>
|
||||
<artifactId>cache-api</artifactId>
|
||||
<version>${cache.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.hazelcast</groupId>
|
||||
<artifactId>hazelcast</artifactId>
|
||||
<version>${hazelcast.version}</version>
|
||||
</dependency>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.hazelcast</groupId>
|
||||
<artifactId>hazelcast</artifactId>
|
||||
<version>${hazelcast.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.atlassian.jira</groupId>
|
||||
<artifactId>jira-rest-java-client-core</artifactId>
|
||||
<version>4.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.atlassian.fugue</groupId>
|
||||
<artifactId>fugue</artifactId>
|
||||
<version>3.0.0-m007</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<repositories>
|
||||
<repository>
|
||||
|
@ -590,6 +600,10 @@
|
|||
<name>bintray</name>
|
||||
<url>http://dl.bintray.com/cuba-platform/main</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>atlassian-public</id>
|
||||
<url>https://packages.atlassian.com/maven/repository/public</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<properties>
|
||||
<multiverse.version>0.7.0</multiverse.version>
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
package com.baeldung.jira;
|
||||
|
||||
import com.atlassian.jira.rest.client.api.JiraRestClient;
|
||||
import com.atlassian.jira.rest.client.api.JiraRestClientFactory;
|
||||
import com.atlassian.jira.rest.client.api.domain.Issue;
|
||||
import com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
public class JiraClient {
|
||||
|
||||
private static final String USERNAME = "jira.user";
|
||||
private static final String PASSWORD = "secret";
|
||||
private static final String JIRA_URL = "http://jira.company.com";
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
final Issue issue = new JiraClient().getIssue("MYKEY-1234");
|
||||
System.out.println(issue.getDescription());
|
||||
}
|
||||
|
||||
private Issue getIssue(String issueKey) {
|
||||
JiraRestClient restClient = getJiraRestClient();
|
||||
Issue issue = restClient.getIssueClient().getIssue(issueKey).claim();
|
||||
|
||||
closeRestClient(restClient);
|
||||
return issue;
|
||||
}
|
||||
|
||||
private JiraRestClient getJiraRestClient() {
|
||||
JiraRestClientFactory factory = new AsynchronousJiraRestClientFactory();
|
||||
|
||||
URI jiraServerUri = getJiraUri();
|
||||
return factory
|
||||
.createWithBasicHttpAuthentication(jiraServerUri, USERNAME, PASSWORD);
|
||||
}
|
||||
|
||||
private URI getJiraUri() {
|
||||
URI jiraServerUri = null;
|
||||
try {
|
||||
jiraServerUri = new URI(JIRA_URL);
|
||||
} catch (URISyntaxException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return jiraServerUri;
|
||||
}
|
||||
|
||||
private void closeRestClient(JiraRestClient restClient) {
|
||||
try {
|
||||
restClient.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue