How can we get all the issues associated to bitbucket commit

DAIVA VARA KUMAR P October 5, 2016

How can we get all the issues associated (through smart commit) to bitbucket commit 

1 answer

0 votes
Kristy
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 5, 2016

Through the UI:

On the commit url (https://bitbucket-server-url/projects/project-name/repos/repo-name/commits/commit-hash) at the top right of the page, there is a section that will show the related issues, next to a JIRA icon. 

 

Edit:

Sorry I didn't realise you were looking for an API.

The REST APIs available for Bitbucket JIRA integration can be found here:

https://developer.atlassian.com/static/rest/bitbucket-server/latest/bitbucket-jira-rest.html

Unfortunately, it does not contain a way to get the issues via a commit hash. In order to do that, you need to call getIssuesForCommit from the JiraIssueService. See https://developer.atlassian.com/static/javadoc/bitbucket-server/latest/jira-api/reference/com/atlassian/bitbucket/integration/jira/JiraIssueService.html for more details.

DAIVA VARA KUMAR P October 5, 2016

Hi Kristy,

Thank you for response. Is there any REST API available to pull out total issues associated to commit? I want to use this list in one of my developed plugin.

Kristy
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 6, 2016

I have edited my answer to include details about the API. Hope that helps

DAIVA VARA KUMAR P November 10, 2016

Thank you very much. This is very helpful for me.

Rinkal Garg July 11, 2018

Hi Daiva and Kristy, Can you please share the code snippet or path where I can find it. Also can you please help me to find the correct jar file which will include JiraIssueService interface. Thanks

Kristy
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 12, 2018

Hi @Rinkal Garg,

To access the API you need to write a Bitbucket Plugin (see https://developer.atlassian.com/server/bitbucket/how-tos/beginner-guide-to-bitbucket-server-plugin-development/ for details).

You can depend on the jar by adding the dependency in your pom.xml

<dependency>
<groupId>com.atlassian.bitbucket.server</groupId>
<artifactId>bitbucket-jira-api</artifactId>
<version>5.12.0</version>
</dependency>

You would then need access to the JiraIssueService from your code (you'd probably wire this up using osgi) and you can call it with something along the lines of:

Set<JiraIssue> issues = jiraIssueService.getIssuesForCommits(ImmutableSet.of("111c0f1b97df94995b91f236300e4ae7f3ddf993", "dd25dda3131911ad842e0b828bff4825fae216e1"));

 

Hope that helps,

Kristy

jv villacorta February 10, 2021

@Kristy ,

I tried your solution above however, I have trouble accessing JiraIssueService.
I tried Component-Import (No qualifying bean of type 'com.atlassian.bitbucket.integration.jira.JiraIssueService')
I tried ComponentLocator but I got null

I dont know where to start fixing to be able to access JiraIssueService

daniel_puiu April 1, 2021

Hello @jv villacorta 

I faced the same issue.

I fixed it by adding to the pom.xml the following missing plugin:

<plugin>
<groupId>com.atlassian.plugin</groupId>
<artifactId>atlassian-spring-scanner-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>atlassian-spring-scanner</goal>
</goals>
<phase>process-classes</phase>
</execution>
</executions>
<configuration>
<scannedDependencies>
<dependency>
<groupId>com.atlassian.plugin</groupId>
<artifactId>atlassian-spring-scanner-external-jar</artifactId>
</dependency>
</scannedDependencies>
<verbose>false</verbose>
</configuration>
</plugin>

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events