I know that one can output messages to TeamCity build logs via specially decorated Write-Host:
write-host "##teamcity[message text='Prepearing backup folder']"
What if I need the message to contain a value of a variable as well.
I've tried the following:
$myFullMessage = "Perpearing backup folder at: " + $path
write-host "##teamcity[message text=$myFullMessage]"
But I get an error in an output stating that the message parameter provided should start with ' character.
Please let me know if I can output messages with variable value part in message body.
The easiest way is a string formatter. Otherwise you get in escape-character hell. Note how in Powershell that you must place two consecutive single-quote characters to put a literal one in the string.
$myFullMessage = "Perpearing backup folder at: " + $path
write-host $( '##teamcity[message text=''{0}'']' -f $myFullMessage )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With