Skip to content

Commit

Permalink
Add Azure Pipelines group logging commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Flepp Jann authored and Flepp Jann committed May 31, 2023
1 parent 8d8d963 commit 0bab09c
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,34 @@ public void Should_Log_Error_Message_With_Data()
Assert.Contains(fixture.Writer.Entries, m => m == $"##vso[task.logissue sourcepath=./code.cs;linenumber=1;columnnumber=2;code=3;type=error;]build error");
}

[Fact]
public void Should_Begin_Group_With_Name()
{
// Given
var fixture = new AzurePipelinesFixture();
var service = fixture.CreateAzurePipelinesService();

// When
service.Commands.BeginGroup("Example Group");

// Then
Assert.Contains(fixture.Writer.Entries, m => m == $"##vso[group ]Example Group");
}

[Fact]
public void Should_End_Group()
{
// Given
var fixture = new AzurePipelinesFixture();
var service = fixture.CreateAzurePipelinesService();

// When
service.Commands.EndGroup();

// Then
Assert.Contains(fixture.Writer.Entries, m => m == $"##vso[endgroup ]");
}

[Fact]
public void Should_Set_Current_Progress()
{
Expand Down
12 changes: 12 additions & 0 deletions src/Cake.Common/Build/AzurePipelines/AzurePipelinesCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,18 @@ public void WriteError(string message, AzurePipelinesMessageData data)
WriteLoggingCommand("task.logissue", properties, message);
}

/// <inheritdoc/>
public void BeginGroup(string name)
{
WriteLoggingCommand("group", name);
}

/// <inheritdoc/>
public void EndGroup()
{
WriteLoggingCommand("endgroup", string.Empty);
}

/// <inheritdoc/>
public void SetProgress(int progress, string currentOperation)
{
Expand Down
11 changes: 11 additions & 0 deletions src/Cake.Common/Build/AzurePipelines/IAzurePipelinesCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@ public interface IAzurePipelinesCommands
/// <param name="data">The message data.</param>
void WriteError(string message, AzurePipelinesMessageData data);

/// <summary>
/// Begin a collapsible group.
/// </summary>
/// <param name="name">The name of the group.</param>
public void BeginGroup(string name);

/// <summary>
/// End a collapsible group.
/// </summary>
public void EndGroup();

/// <summary>
/// Set progress and current operation for current task.
/// </summary>
Expand Down

0 comments on commit 0bab09c

Please sign in to comment.