PowerShell Step - New lines in setParameter

I am trying to use setParameter in a PowerShell step to set a parameter that must be newline separated.

I am using a command similar to this:

Write-Host "##teamcity[setParameter name='name' value='$val']"

Having actual newlines in the PowerShell variable does not work as it resolves like this:

"##teamcity[setParameter name='name' value='val1
val2']"

I tried adding "\n" and this did not get interpreted as a new line:

"##teamcity[setParameter name='name' value='val1\nval2']"

Is there a way to include new lines or a way to append a new line to an existing parameter?

0
2 comments

Hello,

TeamCity uses a vertical bar | as an escape character. You can find more about escape values in TeamCity here:

https://www.jetbrains.com/help/teamcity/service-messages.html#Escaped+Values

As such, the following should work:

"##teamcity[setParameter name='name' value='val1|nval2']"

Thank you,

Guilherme

 

0

Thanks Guilherme, that solved my problem.

0

Please sign in to leave a comment.