I am trying to do what I thought would be simple enough but I have hit a wall.
When an issue is transitioned (got this),
I want to ADD the earliestUnreleasedVersion() to the fixVersion field. All I can do at present is REPLACE the value.
Hi @jeff.kehler , for adding to existing field values you need to use advanced edit JSON. Is that what you are doing? Please see this article that illustrates this for the labels field. You can easily adapt to fixVersions. advanced-field-editing-using-json
Hi @jeff.kehler
Yes, and...to Jack's suggestions...
Once you have learned about making the updates with JSON to "add" a Fix Version, there are several ways to identify the earliest unreleased version to add it:
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.
@Jack Brickey @Bill Sheboy All I am trying to do is ADD the "Next release by release date" to any existing values already present. I used the brute force method above.
I have the right values captured in variables. I get exactly what I want for the fixVersion field in my audit log. I just cannot find the path to get the values in the fixVersion field.
Capture existing values in fixVersion in new Variable
Set fix Version to Next unreleased by release date. Fix version is selected
Here I had to add a 5x re-fetch delay allowing time for logic to execute and populate fixVersion field.
Capture "new" existing value in fixVersion in new Variable
From here I have tried everything I could find but nothing worked
Simply adding both variables in the EDIT issue fields as smart values.
i.e. {{varNextRelease}} , {{varCurrentFixVersions}} NO GO But selecting 2 other named releases/versions works fine
I have tried custom JSON NO GO But no errors in audit log AND both variables have exactly what I want. This just clears the fixVersion field; whether I use ADD or SET, makes no difference.
If I reverse the field order, I end up with just the varNextRelease
{
"fields": {
"fixVersions": [
{
"add": {
"name": "{{{varCurrentFixVersions}},{{varNextRelease}}"
}
}
]
}
}
I have gone to some AI and all I got was the same things I found, none worked.
I find it hard to believe that something so simple, as appending rather then replacing could be this difficult. Manually it is simple. Doing bulk updates, it is simple.
I have to just be missing something ... simple.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
First thing: if the version update with Edit Issue is taking so long it requires multiple Re-fetch Issue actions to succeed, you may want to use another method (i.e., the REST API call). One of those re-fetches should have been enough for this type of update.
Moving on with what you have started already...
In this case, you are trying to set the field and not use "add" with JSON. Thus the syntax will be this, as Jack first described:
{
"fields": {
"fixVersions": [
{ "name": "version1" },
{ "name": "version2" }
]
}
}
Thus the key is how to merge those entries in the variables...
First, when saving the current versions, I recommend taking complete control of the delimiters to avoid surprises:
Now concatenate on the new one with this:
{{varCurrentFixVersions.concat(",").concat(varNextRelease)}}
That is now a comma-separated values list of version names. You may want to consider a condition check in case the field had no existing version values.
Finally, that expression can be split() into a list to dynamically generate the JSON for the update:
{
"fields": {
"fixVersions": [
{{#varCurrentFixVersions.concat(",").concat(varNextRelease).split(",").distinct}}
{ "name": "{{.}}" } {{^last}}, {{/}}
{{/}}
]
}
}
That {{^last}}, {{/}} part conditionally adds the trailing comma so the JSON parsing does not fail.
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.
@Bill Sheboy Thanks for the response.
I am still not able to get it working as needed. Not sure I am following.
{
"fields": {
"fixVersions": [
{{#varCurrentFixVersions.concat(",").concat(varNextRelease).split(",")}}
{ "name": "{{.}}" } {{^last}}, {{/}}
{{/}}
]
}
}
The end result in the issue itself is still, just replacement of the original value with the latest.
I cannot see why the first variable has the braces, but I am guessing that is causing the issue?
I am also not clear where I am to do the following.
Now concatenate on the new one with this:
{{varCurrentFixVersions.concat(",").concat(varNextRelease)}}
I am not seeing in your outline, the step where I actually set and capture the varNextRelease, so I kept those steps "as is" and assumed the concatenation was handled in the advanced edit step???
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry, I should have tested that earlier post rather than just typing it in.
It appears joining the fix versions adds square brackets for array notation, so I added a substringBetween("[", "]") call to remove them. Please see the adjustment I made to capture varCurrentFixVersions.
Update: the above statement handled the typo in the first variable, creating nested lists with square brackets. After that was corrected the substringBetween() call could be removed.
With that change, it should all work. And so the overall rule flow is this:
If that does not work, please write each created variable and the JSON expression to the audit log and post what you see.
Tip: you could create another variable to build the JSON, perhaps named varJson, so it can be logged and then used in the edit as {{varJson}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Bill Sheboy Thank you for all your help.
There were a few errors needing correction. Above we had "issues.fixVersion.name" which should be "issue.fixVersion.name".
I also did not end up needing the substringBetween("[", "]") call addition. I removed the space after the comma in the JSON, and that seemed to fix things.
In any case, with some trial and error, this is what I have, now working. Still seems like A LOT of extra work to just "add" an item to an array versus "replacing". :-)
Tested & Passed in all scenarios.
RULE SET UP
KEY NOTE FOR OTHER NOOBS LIKE ME: Ensure no field is selected in EDIT drop down when using advanced/JSON
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Well done!
For your test cases 4-6, and to avoid errors from attempts to add duplicate versions in the JSON, you could add .distinct after the split(",") as that will remove the duplicates.
Regarding the typo {{issues... versus {{issue... thanks for seeing that! It was a coincidence it worked as the smart value {{issues}} (plural) is a feature of bulk-issue handling of triggers and branches for Jira Server and Data Center automation. (Jira Cloud uses Lookup Issues instead.) I recall testing it several years ago and found it inconsistently worked with Cloud; IMO it probably should throw an error as it is unsupported.
And so, that is what caused the difference with the square brackets: the plural smart value detected possible nested lists (i.e., version lists within an issue list) and so added brackets around the nested list.
I have updated my earlier post accordingly.
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.