Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH1121: Add support for 'setParameter' service message to TeamCityProvider + … #1114

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/Cake.Common.Tests/Unit/Build/TeamCity/TeamCityProviderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,23 @@ public void Should_Use_Provided_DotCover_If_ToolPath_Is_Not_Null()
fixture.Log.AggregateLogMessages());
}
}

public sealed class TheSetParameterMethod
{
[Fact]
public void SetParameter_Should_Write_To_The_Log_Correctly()
{
// Given
var fixture = new TeamCityFixture();
var teamCity = fixture.CreateTeamCityService();

// When
teamCity.SetParameter("internal.artifactVersion", "1.2.3.4");

// Then
Assert.Equal("##teamcity[setParameter name='internal.artifactVersion' value='1.2.3.4']" + Environment.NewLine,
fixture.Log.AggregateLogMessages());
}
}
}
}
14 changes: 14 additions & 0 deletions src/Cake.Common/Build/TeamCity/TeamCityProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,20 @@ public void SetBuildNumber(string buildNumber)
WriteServiceMessage("buildNumber", buildNumber);
}

/// <summary>
/// Tells TeamCity to set a named parameter with a given value
/// </summary>
/// <param name="parameterName">The name of the parameter to set.</param>
/// <param name="parameterValue">The value to set for the named parameter.</param>
public void SetParameter(string parameterName, string parameterValue)
{
WriteServiceMessage("setParameter", new Dictionary<string, string>
{
{ "name", parameterName },
{ "value", parameterValue }
});
}

private void WriteServiceMessage(string messageName, string attributeValue)
{
WriteServiceMessage(messageName, new Dictionary<string, string> { { " ", attributeValue } });
Expand Down