Publishing test results through command line test

2019-02-25 05:02发布

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%

2条回答
够拽才男人
2楼-- · 2019-02-25 05:21

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

查看更多
3楼-- · 2019-02-25 05:23

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

查看更多
登录 后发表回答