Skip to content

Commit 8db9460

Browse files
yasin3061maibin
authored andcommitted
BAEL-1139 How to Integration with the JIRA API (eugenp#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
1 parent 8ed5c8e commit 8db9460

2 files changed

Lines changed: 77 additions & 6 deletions

File tree

‎libraries/pom.xml‎

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -569,12 +569,22 @@
569569
<groupId>javax.cache</groupId>
570570
<artifactId>cache-api</artifactId>
571571
<version>${cache.version}</version>
572-
</dependency>
573-
<dependency>
574-
<groupId>com.hazelcast</groupId>
575-
<artifactId>hazelcast</artifactId>
576-
<version>${hazelcast.version}</version>
577-
</dependency>
572+
</dependency>
573+
<dependency>
574+
<groupId>com.hazelcast</groupId>
575+
<artifactId>hazelcast</artifactId>
576+
<version>${hazelcast.version}</version>
577+
</dependency>
578+
<dependency>
579+
<groupId>com.atlassian.jira</groupId>
580+
<artifactId>jira-rest-java-client-core</artifactId>
581+
<version>4.0.0</version>
582+
</dependency>
583+
<dependency>
584+
<groupId>com.atlassian.fugue</groupId>
585+
<artifactId>fugue</artifactId>
586+
<version>3.0.0-m007</version>
587+
</dependency>
578588
</dependencies>
579589
<repositories>
580590
<repository>
@@ -590,6 +600,10 @@
590600
<name>bintray</name>
591601
<url>http://dl.bintray.com/cuba-platform/main</url>
592602
</repository>
603+
<repository>
604+
<id>atlassian-public</id>
605+
<url>https://packages.atlassian.com/maven/repository/public</url>
606+
</repository>
593607
</repositories>
594608
<properties>
595609
<multiverse.version>0.7.0</multiverse.version>
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package com.baeldung.jira;
2+
3+
import com.atlassian.jira.rest.client.api.JiraRestClient;
4+
import com.atlassian.jira.rest.client.api.JiraRestClientFactory;
5+
import com.atlassian.jira.rest.client.api.domain.Issue;
6+
import com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory;
7+
8+
import java.io.IOException;
9+
import java.net.URI;
10+
import java.net.URISyntaxException;
11+
12+
public class JiraClient {
13+
14+
private static final String USERNAME = "jira.user";
15+
private static final String PASSWORD = "secret";
16+
private static final String JIRA_URL = "http://jira.company.com";
17+
18+
public static void main(String[] args) {
19+
20+
final Issue issue = new JiraClient().getIssue("MYKEY-1234");
21+
System.out.println(issue.getDescription());
22+
}
23+
24+
private Issue getIssue(String issueKey) {
25+
JiraRestClient restClient = getJiraRestClient();
26+
Issue issue = restClient.getIssueClient().getIssue(issueKey).claim();
27+
28+
closeRestClient(restClient);
29+
return issue;
30+
}
31+
32+
private JiraRestClient getJiraRestClient() {
33+
JiraRestClientFactory factory = new AsynchronousJiraRestClientFactory();
34+
35+
URI jiraServerUri = getJiraUri();
36+
return factory
37+
.createWithBasicHttpAuthentication(jiraServerUri, USERNAME, PASSWORD);
38+
}
39+
40+
private URI getJiraUri() {
41+
URI jiraServerUri = null;
42+
try {
43+
jiraServerUri = new URI(JIRA_URL);
44+
} catch (URISyntaxException e) {
45+
e.printStackTrace();
46+
}
47+
return jiraServerUri;
48+
}
49+
50+
private void closeRestClient(JiraRestClient restClient) {
51+
try {
52+
restClient.close();
53+
} catch (IOException e) {
54+
e.printStackTrace();
55+
}
56+
}
57+
}

0 commit comments

Comments
 (0)