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)}}
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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)}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I believe the problem is using multiple smart value expressions in the Create Version action's name field. I just tested and this works:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I guess it just does not work, it would say forget about it for now...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Zhengguan Li and Welcome to the Atlassian Community!
I tested it, and I'm getting success in automation. Can you provide more information and screenshots related to automation?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for quick reply, I attached the screenshot in Bill's thread
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@zhen I don't know if you are still struggling with this, but I experienced a similar issue, where my smart value variables were returning empty when using asNumber (without returning an error in the audit log).
I discovered that asNumber is not supported by my Jira Software product version (Datacenter). This function appears to only be supported by Jira Software Cloud. My final solution was similar, but I used math expressions found here instead of asNumber: https://confluence.atlassian.com/automation/examples-of-using-math-expression-smart-values-993924632.html.
I hope this helps save someone time in the future.
Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.