Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,369,304
Community Members
 
Community Events
168
Community Groups

How to add version numbers to all Jira issues in a release?

I have Jira, Bitbucket Server, and Bamboo.

When I make a release, I would like automatically to stamp the release number as the Fix Version for all Jira issues detected in the release.

I found REST API endpoints for Jira that seems to be appropriate:

POST: /rest/api/2/version (to create a version)
PUT: /rest/api/2/issue/ISSUE-1 (to update the issue with new fixVersion)

But I can't find any REST API that gets a list of Jira issues related to a release. 

I am flexible; we can work with the issues related to a given commit when Bamboo does the build, or we can look at the issues included when Bamboo makes a new release (i.e. since the last release). Either way will work for me.

What's the API to use?

1 answer

1 accepted

2 votes
Answer accepted
Warren Rising Star Jul 11, 2019

Hi @shaulbehr 

Firstly, this is the server API documentation which will become your friend if you're doing any API work.

/rest/api/2/search is probably the most flexible call for you to use, because you append ?jql= and then use any JQL you like. It could be sprint= or fixVersion= or created>"" - it's up to you to build a JQL which returns all items you're expecting.

Hi Warren, thanks for the reference!

I took a look at the search fields available, and there doesn't seem to be anything relating to either Git commits or Bamboo releases. I tried doing a search on the Jira website itself, and can't find anything relevant to search on. Did I miss something?

Anyway, I don't think the endpoint I want is going to be in the Jira API; it's more likely to be in Bitbucket or Bamboo. That's because my starting point is either a commit number (Bitbucket) or a release number (Bamboo), from which I want to retrieve the related Jira issues. I know it must be possible, because Bitbucket and Bamboo themselves show you very helpfully which Jira issues are linked to pull requests or new releases. I just need to find out what APIs they are using there.

Any ideas?

Warren Rising Star Jul 11, 2019

Hi @shaulbehr 

This is the Bitbucket server API and this is (I think) the cloud version. I have used both to get me successfully using the Bitbucket API.

So I found this API being called in Bitbucket:

/rest/jira/latest/projects/LS/repos/my-proj/pull-requests/3772/issues

That's the kind of endpoint I'm looking for, though it's not exactly right, because this gives the issues per pull request, whereas I want the issues per commit. This also must exist, because I can see it on the "commit" screen, as highlighted below:

2019-07-11 13_48_04-LightSail _ API _ bfaf95ed9e0 - Bitbucket.png

I looked in the developer tools and couldn't find the call that returns the issue numbers related to the commit, though.

What is the call?

Got it! It's this one:

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/commits/{commitId}

At the bottom of the response is:

"properties": {
"jira-key": [
"LIGAPI-4352"
]
}

Thanks for your help!

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events