Question

i´m completly exhausted. jenkins will not finish successfull :)

maybe some of you can help me out? the ant jenkins job includes javadoc plugin, publish html reports plugin and junit test-result plugin. configuration is complete default e.g. no path variables or whatever..

Started by an SCM change
Started by user anonymous
Building in workspace /var/lib/jenkins/jobs/TicTacToe/workspace
Updating http://xxx.xxx.xxx.xxx/svn/repo/projekt at revision '2014-01-24T15:21:33.486 +0100'
U         build.xml
U         .classpath
At revision 20
[workspace] $ ant
Buildfile: /var/lib/jenkins/jobs/TicTacToe/workspace/build.xml

build-subprojects:

init:

build-project:
     [echo] TicTacToe: /var/lib/jenkins/jobs/TicTacToe/workspace/build.xml

build:

BUILD SUCCESSFUL
Total time: 0 seconds
Publishing Javadoc
[htmlpublisher] Archiving HTML reports...
Recording test results
None of the test reports contained any result
Build step 'Publish JUnit test result report' changed build result to FAILURE
Finished: FAILURE

and the eclipse structure:

enter image description here

the (simple) tests:

package tictactoe;

import junit.framework.TestCase;

import org.junit.Assert;
import org.junit.Test;

//@RunWith(Suite.class)
//@SuiteClasses({Tests.class})
public class FieldTest extends TestCase {
    @Test
    public void testSchlange() {
        String schlange = new String();
        Assert.assertTrue(schlange.isEmpty());
    }

    @Test
    public void testAdd() {
    Assert.assertFalse(false);
    }
}

and the build.xml:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- WARNING: Eclipse auto-generated file.
              Any modifications will be overwritten.
              To include a user specific buildfile here, simply create one in the same
              directory with the processing instruction <?eclipse.ant.import?>
              as the first entry and export the buildfile again. --><project basedir="." default="build" name="TicTacToe">
    <property environment="env"/>
    <property name="ECLIPSE_HOME" value="../../"/>
    <property name="junit.output.dir" value="junit"/>
    <property name="debuglevel" value="source,lines,vars"/>
    <property name="target" value="1.7"/>
    <property name="source" value="1.7"/>
    <path id="TicTacToe.classpath">
        <pathelement location="bin"/>
        <pathelement location="jfxrt.jar"/>
        <pathelement location="hamcrest-core-1.3.jar"/>
        <pathelement location="junit-4.11.jar"/>
    </path>
    <target name="init">
        <mkdir dir="bin"/>
        <copy includeemptydirs="false" todir="bin">
            <fileset dir="src">
                <exclude name="**/*.launch"/>
                <exclude name="**/*.java"/>
            </fileset>
        </copy>
    </target>
    <target name="clean">
        <delete dir="bin"/>
    </target>
    <target depends="clean" name="cleanall"/>
    <target depends="build-subprojects,build-project" name="build"/>
    <target name="build-subprojects"/>
    <target depends="init" name="build-project">
        <echo message="${ant.project.name}: ${ant.file}"/>
        <javac debug="true" debuglevel="${debuglevel}" destdir="bin" includeantruntime="false" source="${source}" target="${target}">
            <src path="src"/>
            <classpath refid="TicTacToe.classpath"/>
        </javac>
    </target>
    <target description="Build all projects which reference this project. Useful to propagate changes." name="build-refprojects"/>
    <target description="copy Eclipse compiler jars to ant lib directory" name="init-eclipse-compiler">
        <copy todir="${ant.library.dir}">
            <fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
        </copy>
        <unzip dest="${ant.library.dir}">
            <patternset includes="jdtCompilerAdapter.jar"/>
            <fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
        </unzip>
    </target>
    <target description="compile project with Eclipse compiler" name="build-eclipse-compiler">
        <property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
        <antcall target="build"/>
    </target>
    <target name="TicTacToe">
        <mkdir dir="${junit.output.dir}"/>
        <junit fork="yes" printsummary="withOutAndErr">
            <formatter type="xml"/>
            <test name="tictactoe.FieldTest" todir="${junit.output.dir}"/>
            <classpath refid="TicTacToe.classpath"/>
        </junit>
    </target>
    <target name="FieldTest">
        <mkdir dir="${junit.output.dir}"/>
        <junit fork="yes" printsummary="withOutAndErr">
            <formatter type="xml"/>
            <test name="tictactoe.FieldTest" todir="${junit.output.dir}"/>
            <classpath refid="TicTacToe.classpath"/>
        </junit>
    </target>
    <target name="junitreport">
        <junitreport todir="${junit.output.dir}">
            <fileset dir="${junit.output.dir}">
                <include name="TEST-*.xml"/>
            </fileset>
            <report format="frames" todir="${junit.output.dir}"/>
        </junitreport>
    </target>
</project>
Was it helpful?

Solution

Usually it works the following way: After you (or in your case jenkins) started the ant-script, you will have some tasks creating folders defined in properties, gathering some java files defined in classpathes, compiling these classes, running tests on them and finally constructing a jar.

To know which task (target) comes first ant usually uses a default-target, which gets started, as soon as you start your build-process. This target has so called dependencies (related targets), which will have to be finished first, before it is going to start.

In your case, your targets don't seem to have any dependencies on your junit targets (some even seem redundand, like TicTacToe and FieldTest seem to be the same). It also seems your ant-script somehow got auto-generated and modified. While modifing them you seem to forget to add your junit targets as dependencies to your targets, so I guess you also miss some basics in ANT.

I suggest to read the following tutorial. It will help you getting started building your own ant-script and there is also a chapter on how to include junit tests in your script. Jenkins seems to be configured fine, since it obviously started your build and tried to generate a report. It just didn't succeed, because your test have never been started to generate the necessary xmls for those reports, which causes the build to fail, eventhough your build-process was successful.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top