3

I'm trying to use vstest.console.exe with the TfsPublisher logger in VSTS (cloud).

There's a URL example shown in the article for TFS onsite, but I'm trying to work out what parameters to use for my VSTS build. The example is:

/logger:TfsPublisher;Collection=http://localhost:8080/tfs/DefaultCollection;TeamProject=MyProject;BuildName=DailyBuild_20121130.1

But I just get an error saying the build cannot be found in the project, e.g.

Error: Build "1234" cannot be found under team project "MyProject".

I believe the problem is the BuildName parameter. My project and build definition have no spaces in the names. I have tried various values, e.g.:

BuildName=%BUILD_BUILDID% (resolves to number, e.g. 1234)
BuildName=%BUILD_DEFINITIONNAME% (resolves to build definition name OK)
BuildName=%BUILD_BUILDURI% (resolves to url, e.g. vstfs:///Build/Build/1234)

The error message confirms that the environment variables seem to be resolving OK, but I can't determine what I should substitute for "DailyBuild_20121130.1" in my case.

Updated: My vstest.console.exe logger parameter currently looks like

/logger:TfsPublisher;Collection=%SYSTEM_TEAMFOUNDATIONCOLLECTIONURI%;TeamProject=%SYSTEM_TEAMPROJECT%;BuildName=%BUILD_BUILDNUMBER%
Andy Joiner
  • 5,932
  • 3
  • 45
  • 72

2 Answers2

3

I effectively got the result I wanted using the Trx logger and one of the "Publish Test Results" build steps:

vstest.console.exe ... /logger:Trx

enter image description here

Andy Joiner
  • 5,932
  • 3
  • 45
  • 72
  • I've had to do the same thing. It seems like after the build has completed then "$(BUILD_BUILDNUMBER)" is enough, but during the built it isn't.. almost as if the build is staged. I've also found that no per test results are reported. I've resorted to producing a .trx then using the inbuilt "Publish Test Results" task too. – paulio Jul 14 '16 at 09:08
1

The build name is generated by "Build number format" under build definition "General" tab. You can get it from "BUILD_BUILDNUMBER" variable. enter image description here

Eddie Chen - MSFT
  • 29,708
  • 2
  • 46
  • 60