How to insert Wiki markup {noformat} into description field

Peter Brodt March 2, 2022

We have a process which creates issues in Jira via Rest API. The description field may contain Wiki markup strings, for example '-- which leads to a strike through. I therefore wrote a listener (create, update) which reads and updates the description field with a {noformat} string at the beginning and the end of the original description text.

The code is like this:

String newDescValue = "{noformat}" + System.getProperty("line.separator") + descValue + System.getProperty("line.separator") + "{noformat}"

The result extremly strange. 

.
.
.
{noformat}
{noformat}
{noformat}
{noformat}
{noformat}
{noformat}
{noformat}
{noformat}
'--RGO/////XBR23/ZR00553/------'
{noformat}
{noformat}
{noformat}
{noformat}
{noformat}
{noformat}
{noformat}
.
.
.
Any idea what groovy, scriptrunner or Jira are doing? Adding the text directly into the UI works fine.

{noformat}
'--RGO/////XBR23/ZR00553/------'
{noformat}

1 answer

1 accepted

0 votes
Answer accepted
Peter-Dave Sheehan
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.
March 2, 2022

You are likely creating a loop.

When you update the description, you trigger the listener again and it triggers another update.

You are lucky it only did it 8 times.

You should first check if the description already contains {noformat} and only update it if it doesn't.

def sep = System.getProperty("line.separator")
def tag = '{noformat}'
if(!descValue.contains(tag){
  descValue = "$tag$sep$descValue$sep$tag"
}
Peter Brodt March 2, 2022

Thanks for your answer. I will have a look next week. Can't really believe this to be true, because I print the variable descValue to the log before actually updating the field and it already looks as described. But we will see.

Peter Brodt August 25, 2022

Hi Peter-Dave again,

we never got it working this way. We got around it by adding the {nofomat} directly into the rest api call.

Peter

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events