Hello!
I've got another automation question for everyone. I am trying to do the following:
Note: The versions will always change, the only thing consistent is that they will all start with either iOS or tvOS and there will only ever be one unreleased version of each kind at any given time.
My idea on this so far has been to attempt this with regex, but I don't think Jira Automation can accept Regex in their lookups. Does anyone have any ideas on this one?
Thanks in Advance!
Oh hi @Heather Ronnebeck - yes what @Bill Sheboy said.
Here's the details from a rule I created and tested:
https://YOURSITE.atlassian.net/rest/api/3/project/{{issue.project.key}}/versions
Headers:
Content-Type: application/json
Authorization: Basic youremail:token base64encoded
{{#webResponse.body}}{{#if(equals(released, false))}}{{name}}{{^last}},{{/}}{{/}}{{/}}
Create variable - {{iOS}}
{{unreleasedVersions.match("(iOS-[^,]*)")}}
Edit issue fields - Advanced
Additional fields:
{
"fields": {
"fixVersions": [{"name" : "{{iOS}}"}]
}
}
}
Create variable - {{tvOS}}
{{unreleasedVersions.match("(tvOS-[^,]*)")}}
Edit issue fields - Advanced
Additional fields:
{
"fields": {
"fixVersions": [{"name" : "{{tvOS}}"}]
}
}
}
So I did end up using Regex, but only because my filter based on platform didn't work:
{{#unreleasedVersions.split(",")}}{{#if(name(match("iOS-.*").size.gt(0)))}}{{.}}{{/}}{{/}}
I was getting this gnarly error:
Error invoking method com.codebarrel.automation.api.component.smartvalues.objectwrappers.CollectionWrapper.Element.get(java.lang.String@320875173) on com.codebarrel.automation.api.component.smartvalues.objectwrappers.CollectionWrapper.Element@823855090: {{#unreleasedVersions.split(",")}}{{#if(name(match("iOS-.*").size.gt(0)))}}{{.}}{{/}}{{/}}
Hi @Darryl Lee
Both the name filtering (by query) and the status filtering may be sent in the original endpoint call using parameters. Further list filtering may only be needed for more advanced name (or other data attribute) filters.
Thanks, and kind regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ohey @Bill Sheboy I looked at the docs for the project versions API endpoint last night and the only query parameters I saw were expand.
OH... but I did not look at the old (v2) endpoints. Get project versions paginated has both query and status parameters you can query. Nifty.
So I guess this could be rewritten (no regex needed) as:
Send Web Request:
https://YOURSITE.atlassian.net/rest/api/2/project/{{issue.project.key}}/version?status=unreleased&query=ios
Headers:
Content-Type: application/jsonAuthorization: Basic youremail:token base64encoded
Edit issue fields - Advanced
Additional fields:
{
"fields": {
"fixVersions": [{"name" : "{{webResponse.body.values.first.name}}"}]
}
}
}
Send Web Request:
https://YOURSITE.atlassian.net/rest/api/2/project/{{issue.project.key}}/version?status=unreleased&query=tvos
Headers:
Content-Type: application/jsonAuthorization: Basic youremail:token base64encoded
Edit issue fields - Advanced
Additional fields:
{
"fields": {
"fixVersions": [{"name" : "{{webResponse.body.values.first.name}}"}]
}
}
}
Two ways to skin a cat. That poor cat. :-D
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
v3 for a paginated list has them too. (It is just above the one you linked to ;^)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
How embarrassing, you're completely right, I just didn't scroll up haha.
I guess I should point out that the endpoint is different by an s:
https://YOURSITE.atlassian.net/rest/api/3/project/{{issue.project.key}}/versions
https://YOURSITE.atlassian.net/rest/api/3/project/{{issue.project.key}}/version
Tricky.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you so much for the help. It has gotten me 95% of the way there, now there's one last kink in my automation which is the scenario of when there are both tvOS and iOS in the field and both versions need to be mapped into the field.
I have tried using
https://<Yoursite>.atlassian.net/rest/api/2/project/{{issue.project.key}}/version?status=unreleased
this to get the versions, which it does.
But then the issue I run into is that I can't get them into the fix versions field. That's where my hiccup is.
I create the variable of {{apple}} with {{webResponse.body.values.name}} and then use {{apple}} to edit the Fix Version field. However, since it does work it doesn't error out on the audit log, but it also doesn't populate the field. Any ideas?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
OH that's tricky. So MAYBE, just maybe instead of doing:
You instead do:
Let me give that a spin.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ah yeah, it works. Here's the iOS IF branch after I created a new IF branch for tvOS and dragged all the actions down to it.
New JSON for adding fixVersions:
{
"update": {
"fixVersions": [{
"add" : {
"name" : "{{iOS}}"
}
}]
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
More like:
Would that work?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I got it!!! It works!!
So what I needed to do was add a few re-fetchs in there and then also make sure I checked off the checkbox for:
Delay execution of subsequent rule actions until we've received a response for this web request
The part that I was stumbling on before you last update @Darryl Lee was the add vs replace.
@Bill Sheboy @Darryl Lee thank you so much for this help. I appreciate it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think if you do two IF-ELSES then both will complete, and you'll get what you want.
I don't think I can advise removing the Delay. You absolutely need to WAIT for the response back from the API before trying to set the version.
I'm surprised if what you wrote worked, @Heather Ronnebeck because historically, if an IF clause failed, the rule would stop. So if the issue only had tvOS, it might not get set. That's why I added the ELSE.
@Bill Sheboy is that your recollection to how IFs used to work?
If Automation has changed how it deals with failed IFs, then... what you could get rid of is your last ELSE statement.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
With the if / else condition, the sections are apparently mutually exclusive: only one (or none) will execute, and...an if / else condition will not halt rule execution. This is based on my testing / observation.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Short answer: the rule will need to use the REST API endpoint (with the Send Web Request action) to find the version to add, filtering by the name prefix and the status, and then add it using JSON.
Kind regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Have you tried something like the example below? I'm using a multi-select list field for testing (customfield_10157 in the images). It also uses regex; you can add another IF condition for the iOS matches.
I hope it's helpful as guidance for you!
- Pablo
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.