我怎么让詹金斯在和蚂蚁一起建房子的时候找到朱妮特?
阅读答案herehere我相信我有一个类路径问题,但我无法解决它。在我的netbeans项目中,我有一个在netbeans中运行良好的junit测试。我将项目推送到git repo,jenkins看到了变化并构建了项目,但是我得到了一堆错误(如下),因为找不到junit。

-do-compile-test:
    [javac] Compiling 1 source file to C:\Jenkins\jobs\demo\workspace\demo\build\test\classes
    [javac] C:\Jenkins\jobs\demo\workspace\demo\test\MainTest.java:6: package org.junit does not exist
    [javac] import org.junit.After;
    [javac]                 ^
    [javac] C:\Jenkins\jobs\demo\workspace\demo\test\MainTest.java:7: package org.junit does not exist
    [javac] import org.junit.AfterClass;
    [javac]

           ^

junit在我的%ANT_HOME%\lib目录中(windows 7 64位)。我的netbeans项目的文件结构如下:
我已经尝试过通过Ant编辑类路径,但我不能让它正常工作。
这是我第一次使用ant、junit和jenkins,但我想我已经接近于让netbeans和git都能正常工作了。我很乐意提供更多信息。已经战斗了3天了,所以任何帮助都将非常感谢。

最佳答案

我知道回信有点晚,但现在我们有办法解决这个问题…
我有同样的问题,我有一个由ant构建的项目,我解决了这个问题,包括到junit.jar和hamcrest-core.jar的build.xml路径
从junit存储库下载junit.jar和hamcrest-core.jar
吉特:https://github.com/junit-team/junit/wiki/Download-and-Install
将文件粘贴到jenkins/hudson服务器的某个位置
编辑
build.xml文件添加以下行:

<property name="JUNIT_HOME" value="path_to_folder_contain_junit_&_hamcrest_jars"/>
<path id="JUnit 4.libraryclasspath">
    <pathelement location="${JUNIT_HOME}/junit.jar"/>
    <pathelement location="${JUNIT_HOME}/hamcrest-core.jar"/>
</path>
<path id="projectname.classpath">
    <pathelement location="your_bin_folder"/>
    <path refid="JUnit 4.libraryclasspath"/>
</path>

<!--in your javac task include the classpath -->
<javac debug="true" debuglevel="${debuglevel}" destdir="your_bin_folder" source="${source}" target="${target}">
    <src path="src"/>
    <classpath refid="projectname.classpath"/>
</javac>

将文件提交到svn、git或任何服务器。
尝试构建。现在junit在您的类路径中,jenkins可以完成构建

09-25 17:07
查看更多