Reputation: 11457
I am creating a screenshot when my NUnit end-to-end test fails and I am trying to publish it with TeamCity (build agent and server both running on Windows) using the following service message (as described here) which I am writing with Console.WriteLine
from an NUnit test:
##teamcity[publishArtifacts 'C:\BuildAgent\work\xxxxxxxxxxxxxxxx\Path\To\My\Stuff\fail.png']
I see the line in the build log:
------- Stdout: -------
##teamcity[publishArtifacts 'C:\BuildAgent\work\xxxxxxxxxxxxxxxx\Path\To\My\Stuff\fail.png']
But TeamCity is not picking up the file, or at least it is not showing up in the build artifacts. How do I make this work?
Upvotes: 5
Views: 1193
Reputation: 2142
Use the NuGet package provided by JetBrains, this takes care of all the subtleties
NuGet Install TeamCity.ServiceMessages
On GitHub: https://github.com/JetBrains/TeamCity.ServiceMessages
Upvotes: 0
Reputation: 3107
You can try Console.Write
instead of Console.WriteLine
(see below).
Anyway, I guess TeamCity don't trap these messages because they are 'test reports' and appended in the buildlog as text output.
My feeling is they are not parsed and then not interpreted by the Build Script Interaction behavior because of the way they are flushed into the build log.
From the Build Script Interaction (TC 7) :
Service messages are used to pass commands/build information to TeamCity server from the build script. In order to be processed by TeamCity they should be printed into standard output stream of the build (otherwise, if the output is not in the service message syntax, it should appear in the build log). A single service message should not contain a newline character inside it, it should not span across multiple lines.
You should put your test artifacts in a specific folder and delay the publish after the tests.
Note that if you don't need to resolve artifact dynamically, you should use the simpliest way : the Artifact paths
in the build configuration general settings.
Upvotes: 0
Reputation: 4923
Try using relative paths. Teamcity should resolve them against build working directory.
Upvotes: 0