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,359,836
Community Members
 
Community Events
168
Community Groups

How to get Jira release version ID by version name from webhookData?

Hi all,

I have a GitHub action to trigger releasing a version in Jira. I send the version name with the webhook data, {{webhookData.version}} returns ABC.

In my rule for the Jira automation, I send a Slack message if there are issues not ready for release. Something like "Version ABC is not ready to be released". I would like to embed the Jira link of the to-be-released version in ABC text. For that, I would need the version ID. For example, in the release version link below the ID is 12345.

https://project.atlassian.net/projects/WEB/versions/12345/tab/release-report-all-issues

Is there a JQL that helps me get this ID when I only know the version name from webhookData 

1 answer

1 accepted

0 votes
Answer accepted

Hi @Kim Ngan Le Dang 

I have given this a go myself and have got it working

As you say, the URL of the Fix Version is built up using the version's ID. so you will need to use {{webResponse.body.fields.fixVersions.id}} to get this. If you wanted the rule to run agnostic of the project it's running from, you can also use {{webResponse.body.fields.project.key}}, otherwise you can not include this and just hard-code the project's key in it's place. So the URL to send to users would look a little something like this:

https://[your_site_name].atlassian.net/projects/{{webResponse.body.fields.project.key}}/versions/{{webResponse.body.fields.fixVersions.id}}/tab/release-report-all-issues

As you are using automation rules, you could extend this further by embedding this URL within some text, using a format of <[url_generated]|[text to show the user in Slack]> such as the below:

 <https://[your_site_name].atlassian.net/projects/{{webResponse.body.fields.project.key}}/versions/{{webResponse.body.fields.fixVersions.id}}/tab/release-report-all-issues|click here> to view the release

Which would look like this, and the link will take you to the link of the release you have specified.

click here.png

Hope this helps!

Hi, thanks for your fast response!

For now, what I did to solve this is that I used the API request in the backend code to get all project's versions, and then looked for the right version object by name, and then got the ID of the version from that object. Afterward, I sent the version name and id in the {{webhookData}}. Then in my rules, I can use {{webhookData.version_id}} to get the ID. The screenshot below is what the rules look like right now.

Screenshot 2022-08-23 at 12.43.46.png

I works but.. long lines of code just to get the version ID. So I'm wondering if there is an API call or a query that I can use directly in the rules to help me get the version ID if I only know the version name.

but as I understood from your answer, you sent an API request in your rules to get your {{webResponse}}, right? What exactly did your request do and how did the URL look?

@Kim Ngan Le Dang I just used an automation rule action to send an empty web request to

https://[my-site-name].atlassian.net/rest/api/latest/issue/ABC-1

So this was just a simple GET request which retrieves the issue data, with some basic auth, and then I used the response to grab the version ID and name.

get request.png

Oh thank you very much!! This is very helpful. I realize that I can get the version ID using the lookupIssues in the request url

https://[my-site-name].atlassian.net/rest/api/issue/{{lookupIssues.first.key}}

and the retrieve id from {{webResponse.body.fields.fixVersions.id}} as you suggest in the previous reply. 

It worked!

No worries, glad you've got it working! :-)

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
Community showcase
Published in Jira Software

An update on Jira Software customer feedback – June 2022

Hello Atlassian Community! Feedback from customers like you has helped us shape and improve Jira Software. As Head of Product, Jira Software, I wanted to take this opportunity to share an update on...

4,960 views 18 31
Read article

Atlassian Community Events