Include generated files in TeamCity artfacts

805 views Asked by At

I am using TeamCity for CI. Some of my unit tests generate files when they are run (browser screenshots when Selenium-based tests fail), and these files get placed in the Environment.CurrentDirectory, e.g.

C:\Program Files (x86)\TeamCity\buildAgent\temp\buildTmp\SYSTEM_servername 2013-12-10 18_05_14\Out

I want to include these files as TeamCity artifacts, but this does not seem possible TeamCity looks for artifacts based on the checkout directory.

One workaround would be to save my generated files to a hard-coded path (C:\temp, for example) but this is not ideal. Is there a cleaner alternative?

1

There are 1 answers

0
juanbas On

In TeamCity you can find some parameters that would point to certain paths.
If you can find one of them that is useful for you, then you can use that parameter in the Artifact Path.
(find the parameters in Parameters tab, on any Build Result log)

For example, I found a parameter that points to:
"D:\BuildAgent\temp\buildTmp" which is called: system.teamcity.build.tempDir

Then I used it on the Artifact Path, but with some tweaks:
%system.teamcity.build.tempDir%\**\Out\errorScreenshots\* => errorScreenshots


Let me tear down that path for you:
"%system.teamcity.build.tempDir%": this parameter goes to folder "D:\BuildAgent\temp\buildTmp".

"\**": enter a folder which name I can't know, in my case it was something like this "srv_teamcity_TEAMCITY-3 2017-06-22 19_35_18" with date and time constantly changing.

"\Out": then enter to "Out" folder.

"\errorScreenshots": then enter to "errorScreenshots" folder. I created this folder in order to place somescreenshots there when error.

"\*": brings any kind of file, for me there were only ".png" files.


" => errorScreenshots": this tells TeamCity to create a folder within the Artifacts view, it's necessary if you have a lot of artifacts shown. It's used to have the things more clear.

Hope you find this reply useful.

Cheers!