Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Smart value for text to number using asNumber does not work

Edited

I have defined a rule to draft next release by incrementing the patching number by 1, the smart value I use is the following. I tested by releasing "test: 0.0.1", however it generate "test: 0.0.". Looks like asNumber does not work for me...

{{version.name.substringAfterLast(".").asNumber.plus(1)}}

3 answers

1 vote
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.
Nov 11, 2023

Hi @Zhengguan Li -- Welcome to the Atlassian Community!

Please try using the straight versus the curly quotation marks to help that expression parse correctly:

{{version.name.substringAfterLast(".").asNumber.plus(1)}}

If that does not work, I suggest building your expression piece by piece until it fails.  That will explain the problem.  For example, first write just the version name to the log.  Then add the substring function, and so on.

Kind regards,
Bill

I am using straight, when I pasted it, somehow it changed, I tried to build piece by piece, it can only work till asNumber

image.png

It can get 1, but the rest are 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.
Nov 12, 2023 • edited

Would you please clarify how you want to increment the version number?  That will help the community to make better suggestions to help.  Thanks!

For example...

You initially described wanting to increment the version name "test 0.0.1".  And it appears you want to increment only the last digit to 2, leading to a new version of "test 0.0.2".

To do that, please try splitting the value into the two parts: value before the last digit and the last digit...and then concatenating the results.  That would be this:

{{version.name.substringBeforeLast(".").concat(".")}}{{version.name.substringAfterLast(".").asNumber.plus(1)}}

Please note this handles only the case of incrementing the last digit after the final period, does not handle errors, and cannot increment the other digits.

Also note: the smart value expression I show appears to be on two lines, but it is not.  That is just the text wrapping in the community posts.

Yes, you are right, if the current version "test: 0.0.1", the new version will be "test: 0.0.2", then "test: 0.0.3"...I am using expression: 

{{version.name.substringBeforeLast(".")}}.{{version.name.substringAfterLast(".").asNumber.plus(1)}}

I tried your solution, still not working..

image.pngimage.png

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.
Nov 12, 2023

Please add a write to the audit log, after the trigger, with this expression.  It may indicate why the value is not working as expected:

version from trigger: !!{{version.name}}!!

This will show if there are extra characters in that name which are preventing the parsing or the conversion.  If that does not help...

 

Another possible cause to this not working is rules can become broken due to several edit / publish cycles.  This can happen due to some apparent problem in the rule editor. 

The way to check for that is:

  1. Disable the rule, wait a minute, re-enable the rule, and then re-test.  If that does not help...
  2. Disable the rule, and re-create the rule as a new one with the same steps.  Then test that rule.

It never works..but I can try disable and enable rules...

This is what I have after adding write to audit log...I guess it just does not work...

image.png

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.
Nov 13, 2023 • edited

I believe the problem is using multiple smart value expressions in the Create Version action's name field.  I just tested and this works:

  • use the Create Variable action to create the new version name
    • name: varNewVersionName
    • smart value: the expression we created earlier
  • in the Create Version action, use {{varNewVersionName}} as the name

Does not work...image.pngimage.png

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.
Nov 13, 2023

Would you please post an image of your Create Variable action? 

Based on what your log is showing, that can be the only place remaining to explain this behavior.  When I tested with exactly the same version name and smart value expression, this worked for me with Jira Cloud's version of automation rules.

 

I saw you also posted "forget about it for now", so please disregard my request if you want to drop this one.  Thanks!

I guess it just does not work, it would say forget about it for now...

0 votes
Murat Seven
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.
Nov 11, 2023

Hi @Zhengguan Li  and Welcome to the Atlassian Community!

Screen Shot 2023-11-11 at 3.20.50 PM.png

 

I tested it, and I'm getting success in automation. Can you provide more information and screenshots related to automation? 

Thanks for quick reply, I attached the screenshot in Bill's thread

Murat Seven
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.
Nov 12, 2023

Hi @Zhengguan Li and thanks for your screenshot.  

 

can you try this smart value please?

{{version.name.substringBeforeLast(".")}}.{{version.name.substringAfterLast(".").asNumber.plus(1)}}

Best,

Murat Seven

Like Bill Sheboy likes this

This is exactly what have, I did not post initially because I think the problem was the latter expression. The last part result is always nothing. I also tried @Bill Sheboy solution using `concat`, but no luck...

This is the screenshot:image.pngimage.png

Murat Seven
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.
Nov 12, 2023

Hi @Zhengguan Li 

I don't see any errors in your expression for "smart value," but there might be a syntax issue. I have two requests:

First, could you try the following smart value with the log action and share the result?

{{version.name.substringAfterLast(".").asNumber}}

Also, could you disable this automation, create a new one, and try it again? Please make sure to recreate the smart value without any spaces between its components.

I don't have space, just the format make it looks like it has. I have tried the troubleshoot blow previously, it can only get current version, but not the rest..

image.png

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events