https://github.com/jetbrains/teamcity.servicemessages
.NET library to deal with TeamCity Service messages
https://github.com/jetbrains/teamcity.servicemessages
c-sharp teamcity teamcity-service-messages
Last synced: 6 months ago
JSON representation
.NET library to deal with TeamCity Service messages
- Host: GitHub
- URL: https://github.com/jetbrains/teamcity.servicemessages
- Owner: JetBrains
- License: apache-2.0
- Created: 2011-10-19T18:30:24.000Z (almost 14 years ago)
- Default Branch: master
- Last Pushed: 2025-03-19T09:19:28.000Z (7 months ago)
- Last Synced: 2025-04-03T03:13:27.692Z (7 months ago)
- Topics: c-sharp, teamcity, teamcity-service-messages
- Language: C#
- Homepage: http://confluence.jetbrains.net/display/TCDL/Build+Script+Interaction+with+TeamCity#BuildScriptInteractionwithTeamCity-ServiceMessages
- Size: 550 KB
- Stars: 45
- Watchers: 19
- Forks: 13
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
## Service Messages .NET library for [
](https://www.jetbrains.com/teamcity/)
[
](https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub) [](https://www.nuget.org/packages/TeamCity.ServiceMessages) [](https://opensource.org/licenses/Apache-2.0) [
](http://teamcity.jetbrains.com/viewType.html?buildTypeId=TeamCityServiceMessages_TeamCityServiceMessages)
This library provides read/write access to TeamCity Service messages.
Take a look at the description of service messages at this [page](
http://confluence.jetbrains.net/display/TCDL/Build+Script+Interaction+with+TeamCity#BuildScriptInteractionwithTeamCity-ServiceMessages).Usage:
======Most use cases are covered in tests.
To create service message, use:
```csharp
JetBrains.TeamCity.ServiceMessages.Write.ServiceMessageFormatter.FormatMessage
```
To parse service messages, use:
```csharp
JetBrains.TeamCity.ServiceMessages.Read.ServiceMessageParser.ParseServiceMessages
```
There is an API to generate TeamCity specific service messages, use:
```csharp
JetBrains.TeamCity.ServiceMessages.Write.Special.ITeamCityWriter
```
to get the instance of the object create an instance of the factory and get it by:
```csharp
new JetBrains.TeamCity.ServiceMessages.Write.Special.TeamCityServiceMessages().CreateWriter()
```for [example](https://dotnetfiddle.net/4SoKKt):
```csharp
// Creating the root writer
using (var writer = new TeamCityServiceMessages().CreateWriter(Console.WriteLine))
// Creating the build log block "Tests"
using (var block = writer.OpenBlock("Tests"))
// Creating the test suite "Tests"
using (var testClass = block.OpenTestSuite("TestClass"))
{
// Creating the successful test
using (var test = testClass.OpenTest("Successful"))
{
test.WriteStdOutput("Some output");
test.WriteDuration(TimeSpan.FromSeconds(1));
}// Creating the ignored test
using (var test = testClass.OpenTest("Ignored"))
{
test.WriteIgnored();
}// Creating the failed test
using (var test = testClass.OpenTest("Failed"))
{
test.WriteFailed("Some message", "Details");
}// Attaching an image to test
using (var test = testClass.OpenTest("Image"))
{
writer.PublishArtifact(Path.GetFullPath("TeamCity.png") + " => TestData");
test.WriteImage("TestData/TeamCity.png", "Team City Logo");
}// Attaching a value to test
using (var test = testClass.OpenTest("Value"))
{
test.WriteValue(1234.56.ToString(CultureInfo.InvariantCulture), "Some Value");
}// Attaching a file to test
using (var test = testClass.OpenTest("File"))
{
writer.PublishArtifact(Path.GetFullPath("TeamCity.png") + " => TestData");
test.WriteFile("TestData/TeamCity.png", "Team City Logo file");
}// Attaching a link to test
using (var test = testClass.OpenTest("Link"))
{
test.WriteLink("https://www.jetbrains.com/", "JetBrains");
}
}
```