Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Jira automation - update issue with release version

Nick January 30, 2024

Hi all,

I hope you can provide some advice for me.

I am using Jira across different platforms (Android and iOS). My user stories are categorized with a component (iOS or Android). I have created two unreleased versions:

[A] 2.1

[iOS] 2.1

Now, I want to set up automation so that when an issue is resolved, the next unreleased release version is automatically added as the fix version to the issue. The challenge is that for Android, it should select the [A] 2.1 version, and for an iOS issue, it should select [iOS] 2.1.

Additionally, I'd like to make it dynamic, so after releasing those versions, when I create two new versions, the automation should automatically pick the new unreleased versions.

This is what I have now:

jira.jpg

 

Do you have any ideas on how to achieve this?

2 answers

1 accepted

0 votes
Answer accepted
Kalyan Sattaluri
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 30, 2024

This requires experts to pitch in. But in the mean time, can you share some more details about your fix version patterns?

- Do you create all your fix versions ahead of time? As in, does your project already have future android & iOS versions in place or will you create a new one only after you have released an existing one? So at any point you only have one unreleased version..

 - Do you populate release dates for your fix versions ahead of time or do you populate only at the time of the release? Or do you not populate at all?

 

Lets assume one of the two below scenarios is true for you:

  • You create new version only after you have released an old one, so at any time, you only have 1 unreleased version in your project for iOS and android.. OR
  • Even if you have created future versions, only the latest one has a release date. All other future versions release date is empty.

 

I think below logic should work:

(btw, Based on the screenshot, I am guessing you are in cloud edition.)

 

  • Trigger: Issue Transitions
  • Condition: if Component/s equals Android
  • Action: web request call to get your versions pointing to below URL: https://yourdomain.net/rest/api/2/project/yourproject/versions
  • Advanced branch: Smartvalue = {{webResponse.body}}, variable = {{varIterate}}
  • Inside Brach, Advanced compare: {{varIterate.name}} contains [A] 
  • Another Advanced compare: {{varIterate.released}} equals false
  • Another Advanced compare: {{varIterate.releaseDate}} does not equal null
  • Then, Edit Issue: Fix Versions = {{varIterate.name}}

 

I havent tried above logic because I am in data center and we dont have advanced branch option but if you have made the API call to fetch your project's version, below thread discusses how to do advanced compare i mentioned..

 https://community.atlassian.com/t5/Jira-Service-Management/Automation-loop-through-WebResponse-results/qaq-p/2140920

you could do similar if conditions for iOS component in the same rule.

Nick January 30, 2024

Hi Kalyan, 

 

Thank you for your detailed answer, very helpful! 

To answer your question's first: 

 

  1. Do you create all your fix versions ahead of time? As in, does your project already have future android & iOS versions in place or will you create a new one only after you have released an existing one? So at any point you only have one unreleased version.. -> I only create a new release after I released an existing one. So there is always 1 unreleased Android and 1 unreleased iOS version. 
  2. Do you populate release dates for your fix versions ahead of time or do you populate only at the time of the release? Or do you not populate at all? -> Only at the time when I release it. So the release date is empty all time until release. 
  3. Yes, it's the cloud edition

 

So I understand your automation! I tried it but I get a 404 error: 

{"errorMessages":["No project could be found with key 'XXX'."],"errors":{}}

 

Maybe our admin disabled the rest API but I need to check that. 

Kalyan Sattaluri
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 30, 2024

404 error could be because of incorrect URL or credentials.

 

First lets eliminate URL issue.

  • Log into your Jira
  • Open new tab
  • paste below URL replacing bolded parts 

https://yourdomain.net/rest/api/2/project/yourproject/versions

Do you see response?

Kalyan Sattaluri
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 30, 2024

below is how mine is for FYI

image.png

Nick January 30, 2024

My bad, I forgot to select the POST method. 

When I open the URL myself I see the response. 

However, the automation now throws an error 405 (405 Method Not Allowed)

Kalyan Sattaluri
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 30, 2024

@Nick 

You need to do a GET call when using above URL.

But before that, we need to ensure you are using the right credentials to authn/authz. In Data Center it is easy, we directly get bearer tokens. However in cloud, there are few additional steps to be able to make web request as listed here.

At a high level:

  • - you need to gather your API token
  • - encode your credentials, which is <youremailID:TokenfromAbovestep> in base64
  • - Use Authorization Basic <encodedstringfromabove> to make your call.

Final result will be the first screenshot listed in the link I posted earlier.

 

If you have not made a web request before, it seems like a lot of steps, so maybe we can wait to see if anyone else has any other options.

If not, we need to resolve your authentication so that we can move onto next steps..

Please review the link above in the mean time..

Nick January 30, 2024

Aah my bad, sorry! 

It worked with the API key, so thanks for the help! 

 

Would be nice if there is also a way to do this without making the API call, because I don't think they will leave it enabled. 

0 votes
Pierre Ibrahim
Contributor
January 30, 2024

Hi @Nick

I feel like this can be done in either two branches, or two different automations altogether.

Are you storing the fix versions in two different custom fields (android and iOS)? Or is the triggering issue itself for an Android/iOS and you're just simply copying a value to the fix version from the triggering issue?

Nick January 30, 2024

Hi Pierre, 

 

Thanks for your answer! 

So what I'm doing is that the story contains the component (Android or iOS).

The automation is triggered by any issue that transitions to a resolved state. 

If that is the case, the automation has an if statement that checks if the component is Android. If that is the case, it should be added to [A] 2.1 in this example.

Of course, I can select that version in the automation but then the automation is not future proof when 2.1 is released and you want to work with 2.2.

Suggest an answer

Log in or Sign up to answer