1

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?

Richard Ev
  • 52,939
  • 59
  • 191
  • 278
  • Usually you add another build step to your build scripts. After tests were executed you can copy all the files you want to the directory harvested by TC. – BartoszKP Dec 10 '13 at 19:20
  • @BartoszKP - could you explain your idea in more detail? – Richard Ev Jan 30 '14 at 16:33
  • Do you use MSBuild? I'll try to create a simple example tomorrow. – BartoszKP Jan 30 '14 at 16:43
  • Sorry, I don't have TC running any more so I can't fix up anything that would look like an answer. Basically, you can some properties from TC into your build, I'm guessing that these include appropriate paths - which include or from which you can deduce harvested folders locations. In your MSBuild script you just use a `Copy` command to copy whatever files you want to these folders. – BartoszKP Jan 31 '14 at 15:13
  • No problem, thanks for your input nonetheless @BartoszKP. – Richard Ev Jan 31 '14 at 15:40
  • Did you ever find a solution to this? I'm just struggling with the same problem: http://stackoverflow.com/questions/22201884/how-can-i-add-a-file-created-by-a-build-process-to-my-nupkg-artifact-in-teamcity – m90 Mar 05 '14 at 15:30
  • @m90 I didn't I'm afraid. It's still on my to-do list... – Richard Ev Mar 05 '14 at 16:40
  • Ok, so I'll let you know if I find out some solution to this. Thanks for the reply. – m90 Mar 05 '14 at 16:45
  • I added a wildcard entry to my `.csproj` like `` which seems to do exactly what I am looking for. Not too sure about unintended sideeffects or clashes with visual studio though. – m90 Mar 13 '14 at 06:07

1 Answers1

3

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!

juanbas
  • 31
  • 3