Skip to content

Commit dfeb573

Browse files
authored
Merge pull request #3994 from BlythMeister/teamcity
TeamCity Messages Enhancements
2 parents ddde07e + 1a23887 commit dfeb573

File tree

2 files changed

+87
-1
lines changed

2 files changed

+87
-1
lines changed

src/Cake.Common/Build/TeamCity/ITeamCityProvider.cs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,39 @@ public interface ITeamCityProvider
153153
void WriteStartProgress(string message);
154154

155155
/// <summary>
156-
/// Write a status message to the TeamCity build log.
156+
/// Write a message to the TeamCity build log. - Messages not added to the build status.
157157
/// </summary>
158158
/// <param name="message">Message contents.</param>
159159
/// <param name="status">Build status.</param>
160160
/// <param name="errorDetails">Error details if status is error.</param>
161161
void WriteStatus(string message, string status = "NORMAL", string errorDetails = null);
162+
163+
/// <summary>
164+
/// Write a status message to the TeamCity build log. - Prepend message to build status.
165+
/// </summary>
166+
/// <param name="message">Message contents.</param>
167+
/// <param name="status">Build status.</param>
168+
void WritePrependBuildStatus(string message, string status = null);
169+
170+
/// <summary>
171+
/// Write a status message to the TeamCity build log. - append message to build status.
172+
/// </summary>
173+
/// <param name="message">Message contents.</param>
174+
/// <param name="status">Build status.</param>
175+
void WriteAppendBuildStatus(string message, string status = null);
176+
177+
/// <summary>
178+
/// Write a status message to the TeamCity build log. - replace existing build status.
179+
/// </summary>
180+
/// <param name="message">Message contents.</param>
181+
/// <param name="status">Build status.</param>
182+
void WriteReplacementBuildStatus(string message, string status = null);
183+
184+
/// <summary>
185+
/// Write a statistic message to the TeamCity build log.
186+
/// </summary>
187+
/// <param name="key">The statistic key.</param>
188+
/// <param name="value">The statistic value.</param>
189+
void WriteStatistic(string key, string value);
162190
}
163191
}

src/Cake.Common/Build/TeamCity/TeamCityProvider.cs

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,54 @@ public void WriteStatus(string message, string status = "NORMAL", string errorDe
120120
WriteServiceMessage("message", attrs);
121121
}
122122

123+
/// <inheritdoc/>
124+
public void WriteAppendBuildStatus(string message, string status = null)
125+
{
126+
var attrs = new Dictionary<string, string>
127+
{
128+
{ "text", $"{{build.status.text}}; {message}" }
129+
};
130+
131+
if (status != null)
132+
{
133+
attrs.Add("status", status);
134+
}
135+
136+
WriteServiceMessage("buildStatus", attrs);
137+
}
138+
139+
/// <inheritdoc/>
140+
public void WritePrependBuildStatus(string message, string status = null)
141+
{
142+
var attrs = new Dictionary<string, string>
143+
{
144+
{ "text", $"{message}; {{build.status.text}}" }
145+
};
146+
147+
if (status != null)
148+
{
149+
attrs.Add("status", status);
150+
}
151+
152+
WriteServiceMessage("buildStatus", attrs);
153+
}
154+
155+
/// <inheritdoc/>
156+
public void WriteReplacementBuildStatus(string message, string status = null)
157+
{
158+
var attrs = new Dictionary<string, string>
159+
{
160+
{ "text", message }
161+
};
162+
163+
if (status != null)
164+
{
165+
attrs.Add("status", status);
166+
}
167+
168+
WriteServiceMessage("buildStatus", attrs);
169+
}
170+
123171
/// <inheritdoc/>
124172
public void ImportData(string type, FilePath path)
125173
{
@@ -198,6 +246,16 @@ public void SetParameter(string parameterName, string parameterValue)
198246
});
199247
}
200248

249+
/// <inheritdoc/>
250+
public void WriteStatistic(string key, string value)
251+
{
252+
WriteServiceMessage("buildStatisticValue", new Dictionary<string, string>
253+
{
254+
{ "key", key },
255+
{ "value", value }
256+
});
257+
}
258+
201259
private void WriteServiceMessage(string messageName, string attributeValue)
202260
{
203261
WriteServiceMessage(messageName, new Dictionary<string, string> { { " ", attributeValue } });

0 commit comments

Comments
 (0)