How to insert a LINEBREAK using the CLI -> setFieldValue

Hello together.

I am using the CLI so set some custom field values and I encounter the problem that I cannot set linebreaks.

I am particularily using the "setFieldValue"-command as in the script below

<PATH TO CLI>/jira --server "http://SERVER" --user "USER" --password "PASSWORD" --action setFieldValue --issue "ISSUE-ID" --field "FIELDNAME" --values "LINE 1 >> HOW TO INSERT NEW LINE HERE << LINE 2" --appendText

I tried a.o. with "\n", "\n ", " \n ","\r\n", "\r\n ", "\\". (All of them just make the charakters in the field, only " \n " brings up an "Exception 1" without any further note.

I have the target field with the "Normal Text Renderer" and with the "Wiki Markup Renderer" configured and editing the field directly (using the Enter Key) successfully creates a linebreak.

Any clue what I have to write there in order to create the linebreak?

Kind regards

Sascha Mareth

7 answers

1 accepted

This widget could not be displayed.

I "solved" this by using Ruby with the jira gem to update the custom field, where "\n" is interpreted as new line.

This particular question still is unanswered, but its not more an issue either.

This widget could not be displayed.

Hi Sascha,

according to the documentation it should work with " \n "

Some text fields support the automatic conversion of " \n " (blanks are significant) to be replaced with a new line character - example: --description "A multi-line text field: \n # line 1 \n # line 2"

https://bobswift.atlassian.net/wiki/display/JCLI/Documentation#Documentation-setFieldValue

But I see you solved it anyway :)

So, the solution was to place the space character before and after the "\n" right?

Hi.

I saw this also and tried it with and without spaces - but in my case nothing really worked (not even the " \n "-version with spaces before and after), so I switched to another method.

Even if this question is not really answered so far, it is also not an "open issue" anymore, and I am not available the next 2 weeks.

Thank you for all your feedback and suggestions anyways.

This widget could not be displayed.

Did you try to print the stack trace of the exception to get a bit more info where the error occurs?

This widget could not be displayed.

Did you try using octal escape, like "\012"?

I tried now, but it does not work either -> using the "Enter"-code just makes the field to be finished and the rest ist cut off.

You should report this issue to Atlassian, because I believe it's a bug in their CLI.

This widget could not be displayed.

I "solved" this by using Ruby with the jira gem to update the custom field, where "\n" is interpreted as new line.

This particular question still is unanswered, but its not more an issue either.

This widget could not be displayed.

The "Exception 1" is not reproducable anymore and I did not find other informations where this occured so far.

This widget could not be displayed.

I am having a similar problem with updating a page with rest, I have tried all the above suggestions but the page appears with no linebreaks nevertheless:

def write_data(auth, html, pageid, title = None):
    info = get_page_info(auth, pageid)
 
    ver = int(info['version']['number']) + 1
 
    ancestors = get_page_ancestors(auth, pageid)
    anc = ancestors[-1]
    del anc['_links']
    del anc['_expandable']
   # del anc['extensions']
 
    if title is not None:
        info['title'] = title
    data = {
        'id' : str(pageid),
        'type' : 'page',
        'title' : info['title'],
        'version' : {'number' : ver},
        'ancestors' : [anc],
        'body'  : {
            'storage' :
            {
                'representation' : 'storage',
                'value' : str(html).replace("[log]","[log]\\\n"),
            }
        }
    }
    data = json.dumps(data)
    url = '{base}/{pageid}'.format(base = BASE_URL, pageid = pageid)
    print(data)
    r = requests.put(
        url,
        data = data,
        auth = auth,
        headers = { 'Content-Type' : 'application/json'}
    )
    r.raise_for_status()
    print("Wrote '%s' version %d" % (info['title'], ver))
    print("URL: %s%d" % (VIEW_URL, pageid))

The print(data) prints the following:

{"id": "118591392", "version": {"number": 26}, "body": {"storage": {"value": "[log]\\\n CLICK on L(1058,443)@S(0)[0,0 1920x1080]\n[log]\\\n

( Ctrl ) TYPE \"n\"\n[log]\\\n CLICK on L(1071,312)@S(0)[0,0 1920x1080]\n[log]\\\n ( Ctrl ) TYPE \"s\"\n", "representation": "storage"}}, "t

ype": "page", "title": "test2", "ancestors": [{"id": "118591369", "type": "page", "title": "test"}]}


And the outcome looks like this:

Screen Shot 2015-04-20 at 15.27.35.png

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Aug 06, 2018 in Jira Service Desk

A is for Activate: Share your top Jira Service Desk onboarding tips for new users!

Hi, everyone! Molly here from the Jira Service Desk Product Marketing Team :).  In the spirit of this month's  august-challenge, we're sourcing stories of Jira Service Desk activation fro...

528 views 23 15
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you