powershell - 使TeamCity识别Powershell消息

标签 powershell teamcity-7.0

如何使用Powershell使TeamCity在构建日志中输出消息?

我正在使用TeamCity 7.1。

这是我的Powershell构建步骤:

脚本是:

write-host "##teamcity[message 'Getting production info']"

if ($LASTEXITCODE -ne 0) {
    write-host "##teamcity[message 'Production Remote Not Found: Creating Remote']"

    write-host "##teamcity[message 'Pushing to Remote']"
    #git push production

} else {
    write-host "##teamcity[message 'write-output: Production Remote Found: Pushing to Remote']"
    #git push production
}

我在构建日志中获得的唯一信息是:
[17:02:58]Skip checking for changes - changes are already collected
[17:02:59]Publishing internal artifacts (1s)
[17:03:00][Publishing internal artifacts] Sending build.start.properties.gz file
[17:02:59]Clearing temporary directory: C:\BuildAgent2\temp\buildTmp
[17:02:59]Checkout directory: C:\BuildAgent2\work\7669b6a04f96908d
[17:02:59]Updating sources: agent side checkout
[17:02:59][Updating sources] VCS Root: Portal Master
[17:02:59][VCS Root: Portal Master] revision: c5c6a9a0d491ee2c64ce98e48b0d67c422237698
[17:02:59][VCS Root: Portal Master] Resetting Portal Master in C:\BuildAgent2\work\7669b6a04f96908d to revision c5c6a9a0d491ee2c64ce98e48b0d67c422237698
[17:02:59]Starting: C:\Windows\sysnative\cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NonInteractive -File C:\BuildAgent2\temp\buildTmp\powershell1349912883332714566.ps1
[17:02:59]in directory: C:\BuildAgent2\work\7669b6a04f96908d
[17:03:00]
[17:03:00]
[17:03:00]
[17:03:00]Process exited with code 0
[17:03:00]Publishing internal artifacts
[17:03:00][Publishing internal artifacts] Sending build.finish.properties.gz file
[17:03:00]Build finished

最佳答案

documentation中所述,“消息”服务消息可以具有多个参数,因此您至少需要指定参数'text':"##teamcity[message text='Getting production info']"
您的脚本将是

write-host "##teamcity[message text='Getting production info']"

if ($LASTEXITCODE -ne 0) {
    write-host "##teamcity[message text='Production Remote Not Found: Creating Remote']"

    write-host "##teamcity[message text='Pushing to Remote']"
    #git push production

} else {
    write-host "##teamcity[message text='write-output: Production Remote Found: Pushing to Remote']"
    #git push production
}

关于powershell - 使TeamCity识别Powershell消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12521647/

相关文章:

sharepoint - SharePoint 2010-添加具有工作流程批准状态和PowerShell的列表项

.net - 从 [regex] 类型加速器表达式中捕获命名组的 PowerShell 语法是什么?

teamcity - 触发选项来设置特定的构建参数?

teamcity - 在 TeamCity "NuGet Pack"运行者类型中,如何避免使用 BasePath 选项?

teamcity - 如何将软件包发布到TeamCity nuget服务器?

powershell - 如何从TeamCity构建配置中设置PowerShell开关参数

powershell - 如何从不同位置删除超过 X 天的多个文件?

powershell - 重命名文件共享中的文件夹

rake - 为什么这个 dotCover rake 任务使用这些相对文件路径失败?

amazon-ec2 - 是否可以让 TeamCity 为构建代理停止和重启 Amazon EC2 实例?