Fill Affected Version with automation

Frank Eilts June 14, 2022

I want to fill the affected version of issues with project automation.
To retrieve the versions i use a web request on:
/rest/api/2/project/ESIGQA/versions
Unfortunatly there seems to be no filter. The result is a json array of Versions.
How can I filter out one value using smart functions?
I also tried to use match on the webhookResponse.body but ithis doesn't work. 
Even:
{{webhookResponse.body.match("(.*)")}}
Returns nothing.

1 answer

0 votes
Bill Sheboy
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.
June 23, 2022

Hi @Frank Eilts 

First thing, I am using Jira Cloud, so what you see may be different for the Data Center/Server version of automation for Jira.  With that disclaimer out of the way...

When I call that REST API method I get all of the versions back.  How do you know which one you want to add to Affects Versions?  Could you instead use Edit Issue and select a relative one, such as with Next Unreleased Version?

Next, if there is a specific one you need, such as by name filtering...Unfortunately smart value, list filtering does not work yet for Data Center/Server.  You could use the match() function with a regular expression if you extract from the correct level in the response.

Kind regards,
Bill

Frank Eilts June 28, 2022

I didn't know the "Next Unreleased Version" value for edit issue. Unfortunatly due to our setup we got multiple products in one project with multiple versions so I can't use the feature.
I try to create a regular expression for it. But I can't get a result.
Shouldn't this return the full body?
{{webhookResponse.body.match("(.*)")}}
When I try it it returns nothing. 

Bill Sheboy
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.
June 28, 2022

Hi, Frank.

Perhaps try first logging the entire body to find the correct location you want to search for the matches.  What exactly are you trying to match on: id, name, etc.?

If you just need the list of version id values, this would work:

{{webhookResponse.body.values.id}}

Frank Eilts July 7, 2022

I tried the following:


webhookResponse.body.first.description
{{webhookResponse.body.first.description}}
webhookResponse.body.first.description.match(" (.*) ")
{{webhookResponse.body.first.description.match(" (.*) ")}}
webhookResponse.body.first.match(" (.*) ")
{{webhookResponse.body.first.match(" (.*) ")}}
webhookResponse.body.values.id
{{webhookResponse.body.values.id}}

Result was:

webhookResponse.body.first.description
wie ALM Zyklus
webhookResponse.body.first.description.match(" (.*) ")
ALM
webhookResponse.body.first.match(" (.*) ")

webhookResponse.body.values.id

I guess match only works on field level.

Frank Eilts July 8, 2022

{{webhookResponse.body.toUpperCase()}}

Is also empty.

Bill Sheboy
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.
July 8, 2022

Correct that you need to reference the specific field to use the matching functions.

Frank Eilts July 20, 2022

I solved this Problem with creating the Version with the Create Version Action.
Then adding the Version with the Edit Action providing a Json for it:

{
"update": {
"versions": [{
"add": {
"name":"<Version Name>"
}
}]
}
}

Like Bill Sheboy likes this

Suggest an answer

Log in or Sign up to answer