Skip to content

Commit

Permalink
(cake-build#4019) Add build status update messages
Browse files Browse the repository at this point in the history
  • Loading branch information
BlythMeister authored and gep13 committed Oct 25, 2022
1 parent 03107f6 commit 1a23887
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/Cake.Common/Build/TeamCity/ITeamCityProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,34 @@ public interface ITeamCityProvider
void WriteStartProgress(string message);

/// <summary>
/// Write a status message to the TeamCity build log.
/// Write a message to the TeamCity build log. - Messages not added to the build status.
/// </summary>
/// <param name="message">Message contents.</param>
/// <param name="status">Build status.</param>
/// <param name="errorDetails">Error details if status is error.</param>
void WriteStatus(string message, string status = "NORMAL", string errorDetails = null);

/// <summary>
/// Write a status message to the TeamCity build log. - Prepend message to build status.
/// </summary>
/// <param name="message">Message contents.</param>
/// <param name="status">Build status.</param>
void WritePrependBuildStatus(string message, string status = null);

/// <summary>
/// Write a status message to the TeamCity build log. - append message to build status.
/// </summary>
/// <param name="message">Message contents.</param>
/// <param name="status">Build status.</param>
void WriteAppendBuildStatus(string message, string status = null);

/// <summary>
/// Write a status message to the TeamCity build log. - replace existing build status.
/// </summary>
/// <param name="message">Message contents.</param>
/// <param name="status">Build status.</param>
void WriteReplacementBuildStatus(string message, string status = null);

/// <summary>
/// Write a statistic message to the TeamCity build log.
/// </summary>
Expand Down
48 changes: 48 additions & 0 deletions src/Cake.Common/Build/TeamCity/TeamCityProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,54 @@ public void WriteStatus(string message, string status = "NORMAL", string errorDe
WriteServiceMessage("message", attrs);
}

/// <inheritdoc/>
public void WriteAppendBuildStatus(string message, string status = null)
{
var attrs = new Dictionary<string, string>
{
{ "text", $"{{build.status.text}}; {message}" }
};

if (status != null)
{
attrs.Add("status", status);
}

WriteServiceMessage("buildStatus", attrs);
}

/// <inheritdoc/>
public void WritePrependBuildStatus(string message, string status = null)
{
var attrs = new Dictionary<string, string>
{
{ "text", $"{message}; {{build.status.text}}" }
};

if (status != null)
{
attrs.Add("status", status);
}

WriteServiceMessage("buildStatus", attrs);
}

/// <inheritdoc/>
public void WriteReplacementBuildStatus(string message, string status = null)
{
var attrs = new Dictionary<string, string>
{
{ "text", message }
};

if (status != null)
{
attrs.Add("status", status);
}

WriteServiceMessage("buildStatus", attrs);
}

/// <inheritdoc/>
public void ImportData(string type, FilePath path)
{
Expand Down

0 comments on commit 1a23887

Please sign in to comment.