forked from joaomatossilva/DateTimeExtensions
-
Notifications
You must be signed in to change notification settings - Fork 1
/
teamcity.psm1
149 lines (117 loc) · 4.52 KB
/
teamcity.psm1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
if ($env:TEAMCITY_VERSION) {
# When PowerShell is started through TeamCity's Command Runner, the standard
# output will be wrapped at column 80 (a default). This has a negative impact
# on service messages, as TeamCity quite naturally fails parsing a wrapped
# message. The solution is to set a new, much wider output width. It will
# only be set if TEAMCITY_VERSION exists, i.e., if started by TeamCity.
$host.UI.RawUI.BufferSize = New-Object System.Management.Automation.Host.Size(8192,50)
}
function TeamCity-TestSuiteStarted([string]$name) {
Write-Output "##teamcity[testSuiteStarted name='$name']"
}
function TeamCity-TestSuiteFinished([string]$name) {
Write-Output "##teamcity[testSuiteFinished name='$name']"
}
function TeamCity-TestStarted([string]$name) {
Write-Output "##teamcity[testStarted name='$name']"
}
function TeamCity-TestFinished([string]$name) {
Write-Output "##teamcity[testFinished name='$name']"
}
function TeamCity-TestIgnored([string]$name, [string]$message='') {
Write-Output "##teamcity[testIgnored name='$name' message='$message']"
}
function TeamCity-TestOutput([string]$name, [string]$output) {
Write-Output "##teamcity[testStdOut name='$name' out='$output']"
}
function TeamCity-TestError([string]$name, [string]$output) {
Write-Output "##teamcity[testStdErr name='$name' out='$output']"
}
function TeamCity-TestFailed([string]$name, [string]$message, [string]$details='', [string]$type='', [string]$expected='', [string]$actual='') {
$output="##teamcity[testFailed ";
if (![string]::IsNullOrEmpty($type)) {
$output += " type='$type'"
}
$output += " name='$name' message='$message' details='$details'"
if (![string]::IsNullOrEmpty($expected)) {
$output += " expected='$expected'"
}
if (![string]::IsNullOrEmpty($actual)) {
$output += " actual='$actual'"
}
$output += ']'
Write-Output $output
}
# See http://confluence.jetbrains.net/display/TCD5/Manually+Configuring+Reporting+Coverage
function TeamCity-ConfigureDotNetCoverage([string]$key, [string]$value) {
Write-Output "##teamcity[dotNetCoverage $key='$value']"
}
function TeamCity-ImportDotNetCoverageResult([string]$tool, [string]$path) {
Write-Output "##teamcity[importData type='dotNetCoverage' tool='$tool' path='$path']"
}
# See http://confluence.jetbrains.net/display/TCD5/FxCop_#FxCop_-UsingServiceMessages
function TeamCity-ImportFxCopResult([string]$path) {
Write-Output "##teamcity[importData type='FxCop' path='$path']"
}
function TeamCity-PublishArtifact([string]$path) {
Write-Output "##teamcity[publishArtifacts '$path']"
}
function TeamCity-ReportBuildStart([string]$message) {
Write-Output "##teamcity[progressStart '$message']"
}
function TeamCity-ReportBuildProgress([string]$message) {
Write-Output "##teamcity[progessMessage '$message']"
}
function TeamCity-ReportBuildFinish([string]$message) {
Write-Output "##teamcity[progessFinish '$message']"
}
function TeamCity-ReportBuildStatus([string]$status, [string]$text='') {
Write-Output "##teamcity[buildStatus '$status' text='$text']"
}
function TeamCity-SetBuildNumber([string]$buildNumber) {
Write-Output "##teamcity[buildNumber '$buildNumber']"
}
function TeamCity-SetBuildStatistic([string]$key, [string]$value) {
Write-Output "##teamcity[buildStatisticValue key='$key' value='$value']"
}
function TeamCity-CreateInfoDocument([string]$buildNumber='', [boolean]$status=$true, [string[]]$statusText=$null, [System.Collections.IDictionary]$statistics=$null) {
$doc=New-Object xml;
$buildEl=$doc.CreateElement('build');
if (![string]::IsNullOrEmpty($buildNumber)) {
$buildEl.SetAttribute('number', $buildNumber);
}
$buildEl=$doc.AppendChild($buildEl);
$statusEl=$doc.CreateElement('statusInfo');
if ($status) {
$statusEl.SetAttribute('status', 'SUCCESS');
} else {
$statusEl.SetAttribute('status', 'FAILURE');
}
if ($statusText -ne $null) {
foreach ($text in $statusText) {
$textEl=$doc.CreateElement('text');
$textEl.SetAttribute('action', 'append');
$textEl.set_InnerText($text);
$textEl=$statusEl.AppendChild($textEl);
}
}
$statusEl=$buildEl.AppendChild($statusEl);
if ($statistics -ne $null) {
foreach ($key in $statistics.Keys) {
$val=$statistics.$key
if ($val -eq $null) {
$val=''
}
$statEl=$doc.CreateElement('statisticsValue');
$statEl.SetAttribute('key', $key);
$statEl.SetAttribute('value', $val.ToString());
$statEl=$buildEl.AppendChild($statEl);
}
}
return $doc;
}
function TeamCity-WriteInfoDocument([xml]$doc) {
$dir=(Split-Path $buildFile)
$path=(Join-Path $dir 'teamcity-info.xml')
$doc.Save($path);
}