Max*_*lov 3 powershell teamcity write-host
我知道可以通过特殊装饰的Write-Host将消息输出到TeamCity构建日志:
write-host "##teamcity[message text='Prepearing backup folder']" 
如果我需要消息包含变量的值,该怎么办?
我尝试过以下方法:
$myFullMessage = "Perpearing backup folder at: " + $path
write-host "##teamcity[message text=$myFullMessage]" 
但是我在输出中收到错误,指出提供的消息参数应该以'字符开头.
如果我可以在消息正文中输出带有变量值部分的消息,请告诉我.
Eri*_*ris 11
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 ) 
| 归档时间: | 
 | 
| 查看次数: | 3842 次 | 
| 最近记录: |