How to insert Wiki markup {noformat} into description field

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
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Mar 02, 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"
}

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.

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