我有一个定义如下的jenkinfile:
stages{
stage("Unit Tests") {
script {
try {
powershell "c:\\'Program Files (x86)'\\NUnit.org\\nunit-console\\nunit3-console.exe (ls -r *\\bin\\Debug\\*.UnitTests.dll | % { $_.FullName } | sort-object -Unique) --result=Caxton.OMX.DevelopBranch.UnitTests.xml"
}
catch (Exception err) {
currentBuild.result = 'SUCCESS'
}
}
stage("Integration Tests") {
script {
try {
powershell "c:\\'Program Files (x86)'\\NUnit.org\\nunit-console\\nunit3-console.exe D:\\Jenkins\\workspace\\'Caxton.OMX (Build and run unit tests for develop branch)'\\Caxton.OMX.IntegrationTests\\bin\\Debug\\Caxton.OMX.IntegrationTests.dll --result=Caxton.OMX.DevelopBranch.IntegrationTests.xml"
}
catch (Exception err) {
currentBuild.result = 'SUCCESS'
}
}
}
现在,我想在构建后操作中发布那些xml文件,该怎么办?我不知道nunit3的参数,但是应该是这样的:
post{
nunit3 testResultFile ' ' ...
}
请向我提供Jenkinfile中nunit3参数的详细信息,或者在这种情况下的示例中更好(我想同时发布两个xml文件)。谢谢
答案 0 :(得分:0)
我为此找到了解决方案。我将以下代码添加到后期构建中:
post
{
always
{
echo "publish the Nunit3 tests"
step([
$class: 'NUnitPublisher',
testResultsPattern: "*.xml",
debug: false,
//keepJUnitReports: true,
//skipJUnitArchiver:false,
failOnError: true,
//failIfNoResults: true
])
}
)
您可以添加更多参数,但是仅使用上面的3个即可将测试发布到Jenkins视图。希望能为与我有同样问题的任何人提供帮助。
答案 1 :(得分:0)