From 8c07d095598c32486724653d240e65ec6d04c7e6 Mon Sep 17 00:00:00 2001 From: "Rauch, Matthias" Date: Tue, 5 Apr 2016 17:46:37 +0200 Subject: [PATCH] Added support for service message "buildProblem" --- teamcity.psm1 | 10 ++++++++++ tests/teamcity.tests.ps1 | 12 ++++++++++++ 2 files changed, 22 insertions(+) diff --git a/teamcity.psm1 b/teamcity.psm1 index 0cbb58f..1ec753d 100644 --- a/teamcity.psm1 +++ b/teamcity.psm1 @@ -138,6 +138,16 @@ function TeamCity-ReportBuildStatus([string]$status=$null, [string]$text='') { TeamCity-WriteServiceMessage 'buildStatus' $messageAttributes } +function TeamCity-ReportBuildProblem([string]$description, [string]$identity=$null) { + $messageAttributes = @{ description=$description } + + if (![string]::IsNullOrEmpty($identity)) { + $messageAttributes.identity=$identity + } + + TeamCity-WriteServiceMessage 'buildProblem' $messageAttributes +} + function TeamCity-SetBuildNumber([string]$buildNumber) { TeamCity-WriteServiceMessage 'buildNumber' $buildNumber } diff --git a/tests/teamcity.tests.ps1 b/tests/teamcity.tests.ps1 index 5c69fbf..ac83c8f 100644 --- a/tests/teamcity.tests.ps1 +++ b/tests/teamcity.tests.ps1 @@ -218,6 +218,18 @@ Describe "TeamCity-ReportBuildStatus" { } } +Describe "TeamCity-ReportBuildProblem" { + It "Writes ##teamcity[buildProblem description='A problem occured.' identity='SOME_IDENTITY']" { + TeamCity-ReportBuildProblem "A problem occured." "SOME_IDENTITY" | ` + Should BeExactly "##teamcity[buildProblem description='A problem occured.' identity='SOME_IDENTITY']" + } + + It "Writes ##teamcity[buildStatus text='A problem occured.'] without optional identity attribute." { + TeamCity-ReportBuildStatus -text "A problem occured." | ` + Should BeExactly "##teamcity[buildStatus text='A problem occured.']" + } +} + Describe "TeamCity-SetBuildNumber" { It "Writes ##teamcity[buildNumber '1.2.3_{build.number}-ent']" { TeamCity-SetBuildNumber "1.2.3_{build.number}-ent" | `