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.
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.