Forums

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

Automation - Set Variable

Jon Hays
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 9, 2024

I am trying to get the Automation to build new sprints using our naming convention.  

<KEY> Sprint <X>   

I have a string of rules, but basically. 

GET Web Request - which returns 

  {maxResults=50, startAt=0, total=1, isLast=true, values=[{id=295, self=https://<DOMAIN>.atlassian.net/rest/agile/1.0/sprint/295, state=active, name=CLD Sprint 1, startDate=2024-12-09T20:38:07.083Z, endDate=2024-12-23T05:00:00.000Z, createdDate=2024-12-06T14:19:28.599Z, originBoardId=54, goal=}]}

Then, I create a variable from this response. 
 
NewSprintNumber - which should see the # after Sprint and Iterate it 1.  

{{webResponse.body.match("name=.*Sprint ([0-9]+)").group(1).asNumber.plus(1)}}


The NewSprintNumber doesn't log, and is not available for later commands.  

Any assistance would be greatly appreciated.  

2 answers

0 votes
Aron Gombas _Midori_
Community Champion
December 10, 2024

I would debug it with this approach: 

  1. Simplify your expression so that it only extracts name, but doesn't do anything more. Pass it to the variable and write the variable to the rule's audit log using the corresponding automation action.
  2. When it works, convert it to a number. Write it to the audit log.
  3. When it works, increment it. Write it to the audit log.

Can you follow me? Try to get the basics work first, and until it does, don't look any further.

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.
December 9, 2024

Hi @Jon Hays -- Welcome to the Atlassian Community!

Scenarios like this with automation often require two steps due to the way smart values like the web response are parsed:

  • first extract the value from the web response, and store it with a created variable action
  • use the variable, converted with asNumber, and then increment it

This approach also helps because the variable may be written to the audit log to confirm your parsing is correct for a match() expression.

And...you may want to adjust the input to that match to reduce the scope, perhaps with:

{{webResponse.body.values.first}}

 

Kind regards,
Bill

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events