Jenkins MSTest-Plugin错误:java.lang.NoClassDefFoundError:hudson / maven / MavenBuild

时间:2016-03-19 02:27:52

标签: maven jenkins msbuild vstest.console

我一直在尝试设置Jenkins来使用我的C#项目进行自动化测试和代码覆盖。我已经使用CoverageConverter.exe生成和转换测试工作和代码覆盖文件(不使用任何插件 - 只是直接批处理文件和原始EXE),但是当我添加MSTest后构建步骤以获取数据时要在Jenkins中显示,我收到以下错误:

[MSTEST-PLUGIN] Processing test results in file(s) **/*.trx
MSTest: D:\Jenkins\jobs\Framework\workspace\TestResults\james_CD 2016-03-18 20_05_13.trx
ERROR: Step ‘Publish MSTest test result report’ aborted due to exception: 
java.lang.NoClassDefFoundError: hudson/maven/MavenBuild
    at hudson.plugins.emma.EmmaPublisher.perform(EmmaPublisher.java:103)
    at hudson.plugins.mstest.MSTestPublisher.perform(MSTestPublisher.java:134)
    at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:782)
    at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:723)
    at hudson.model.Build$BuildExecution.post2(Build.java:185)
    at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:668)
    at hudson.model.Run.execute(Run.java:1763)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:98)
    at hudson.model.Executor.run(Executor.java:410)
Caused by: java.lang.ClassNotFoundException: hudson.maven.MavenBuild
    at jenkins.util.AntClassLoader.findClassInComponents(AntClassLoader.java:1376)
    at jenkins.util.AntClassLoader.findClass(AntClassLoader.java:1326)
    at jenkins.util.AntClassLoader.loadClass(AntClassLoader.java:1079)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 11 more

尽管有错误,但“测试结果趋势”图表显示在项目页面上并且看起来是正确的,并且有一个“代码覆盖率趋势”部分,但图片链接已损坏。

我正在使用以下批处理代码运行测试和代码覆盖率:

@ECHO "`nRunning tests`n---------------------------" 
"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" TestFramework\bin\Release\TestFramework.dll /EnableCodeCoverage /Settings:TestFramework\Settings.testsettings /Logger:trx
@ECHO %ERRORLEVEL%
REM @IF %ERRORLEVEL% NEQ 0 EXIT 1

@ECHO "`n`nConverting code coverage results`n---------------------------" 
@IF EXIST emma\. rd emma /s /q >nul
md emma
del emma\temp.coverage /Q >nul
for /R TestResults %%f in (*.coverage) do copy "%%f" emma\temp.coverage /B /Y
"C:\Program Files\JenkinsUtilities\CoverageConverter\CoverageConverter.exe" /in:emma\temp.coverage /out:emma\coverage.xml /xsl:"C:\Program Files\JenkinsUtilities\MSTestCoverageToEmma.xsl"
goto END

我从另一个类似项目工作的Jenkins系统复制了基本流程,但找不到系统之间的任何相关差异。

我已经尝试过: 1.更新Java 2.更新Jenkins 3.卸载并重新安装MSBuild,MSTest,MSTest Runner和VSTest Runner以及Maven Integration插件。

我觉得我现在非常接近,但我对Java的经验很少,所以此时我无法纠正这个错误。任何人都可以帮我诊断ClassNotFoundException吗?

1 个答案:

答案 0 :(得分:0)

在拼命浏览日志并安装Eclipse(在另一台机器上)以查看java文件后,它开始意外地工作。它可能与安装JaCoCo插件有关,当我注意到我之前安装的用于显示结果的Emma Line Coverage插件表明它已被JaCoCo插件取代时,我也安装了该插件。