Escaping backslashes in CI output

I have problem with outputting network path as log messages and as comments.

\\serverHostname\data\output\master
Outputted to comment or log message look like this β†’ \serverHostname\data\output\master

\\serverHostname\data\output\release\branch
Outputted to comment or log message look like this β†’ \serverHostname\data\output elease\branch

So 2 backslashes are escaped to one, and \r is escaped to return carriage ?

When I escape \\ with \\\\, the output is \\\\ :smiley:
When I escape \r with \\r, the output is \release :smiley:

Hi Michal,

What action or code are you using to output the log messages and comments?

No escaping is required when using the Log Entry action:

Log output:

Comment output:
image

From your previous posts, I’m guessing that you are outputting the log messages and comments from a Powershell script. In this case, you do have to escape all backslashes. e.g.

write-Host "@@continua[message value='\\\\serverHostname\\data\\output\\master' status='information']"
write-Host "@@continua[message value='\\\\serverHostname\\data\\output\\release\\branch' status='information']"

write-Host "@@continua[addBuildComment comment='\\\\serverHostname\\data\\output\\master']"
write-Host "@@continua[addBuildComment comment='\\\\serverHostname\\data\\output\\release\\branch']"

This outputs the following to the log:
image

And the following comments:
image

See Custom Log Messages.

1 Like