2011-10-22 44 views
1

我已经使用在Teamcity中运行的psake编写了构建脚本。从powershell执行时,Teamcity不会检测到msbuild和nUnit失败

我有Teamcity 6.0,所以我从.cmd运行psake,但我不认为这会改变任何东西。

一切工作正常,但我有两个问题。

  1. Nunit没有与Teamcity进行通信,所以当测试失败时,Teamcity说一切正常。

  2. MsBuild表现相同。即使构建失败,Teamcity也会报告成功。

我想知道Teamcity如何检测这些故障。

这里是我的示例脚本:https://github.com/MikeEast/BuildTests/blob/master/build/build.ps1

回答

3

你可能会需要通过其简单而优雅的build status notification system给自己通知的TeamCity。

例如,您可以在PowerShell脚本中输出以下消息到标准输出。

##teamcity[buildStatus status='FAILURE' text='Some error message'] 
+1

而且,幸运的你,TeamCity的只是[发布了一个lib](http://nuget.org/List/Packages/TeamCity.ServiceMessages)来创建这些消息! –

+0

它的工作原理,但我希望有一些神奇的东西。像mspec.exe有一个'--teamcity'开关可以产生这个。我曾希望TeamCity Nunit testrunner以某种方式拥有同样的东西。 –

2

我有TeamCity的工作(与TeamCity的版本6.5.4我必须补充)是使用在psake下载提供的TeamCity的模块的方式。

添加到您的脚本:

... 
Import-Module "$build_dir\psake\teamcity.psm1" 

#Tasks here 
... 
Remove-Module teamcity 

#End Of File 

我有我已经把模块所以build文件夹,所有我的建立可以访问它。

然后它开箱即用。我不使用

内置的NUnit的亚军,虽然,我也把NUnit的控制台在我的build文件夹中,然后调用与每个单元测试组件:

Task Test -depends Build { 
    $testAssemblies = (get-childitem $base_dir -r -i "*UnitTests.dll" -exclude "*.config" -Name | Select-string "bin") 
    foreach($test_asm_name in $testAssemblies) { 
     $full_test_assembly_name = "$base_dir\$test_asm_name" 
     Exec { invoke-expression "$nunitconsole_path $full_test_assembly_name" } 
    } 
} 
+0

我们这样执行xunit:exec {&“$ lib_dir \ xunit \ xunit.console.clr4.exe”“$($ p.BuildDir)\ $($ p.Name).dll”/ nunit“$($ p.BuildDir)\ results.xml“; }它的效果很好。但是,构建总是成功的,当出现测试问题时它会失败。 –

相关问题