Ant没有运行所有目标

时间:2012-02-21 13:54:36

标签: ant jenkins

我有以下没有运行目标“prepForDeployment”和“deployToStaging”的ant文件。这个任务由Jenkins运行,当我查看测试的控制台输出时,我没有收到任何构建错误。

 <?xml version="1.0" encoding="UTF-8"?>
   <project name="deploy" default="runUnitTests" basedir=".">
    <description>
        Deploys to staging.
    </description>

    <target name="init">

        <taskdef name="mxunittask" classname="org.mxunit.ant.MXUnitAntTask" classpathref="project.classpath" />

        <!-- dump the properties -->
        <echoproperties prefix="test" />
    </target>

    <target name="clean" depends="init">
        <mkdir dir="${test.junitoutput}" />
    </target>

    <target name="runUnitTests" depends="init,prepForTests">
        <mkdir dir="${test.output.xml}/unit" />
        <runTestDirectory directoryName="." excludes=""/>
    </target>

    <target name="runAllTests" description="Make output directories and run the MXUnit task" depends="init,clean,runUnitTests">
        <!-- generate pretty reports -->
        <antcall target="junitreport" />
        <fail if="tests.bombed" message="Failing the build due to test failures"/>
    </target>


    <target name="junitreport" depends="init" description="Runs the report without running the tests">
        <junitreport todir="${test.junitoutput}">
            <fileset dir="${test.output.xml}">
                <include name="*.xml" />
            </fileset>
            <report format="frames" todir="${test.junitoutput}" />
        </junitreport>
    </target>

    <target name="prepForTests">
        <!-- just a bunch of replace tasks, runs OK -->
    </target>


    <target name="prepForDeployment" depends="init">

        <replace file="Application.cfc">
            <replacetoken>dbcreate="dropcreate"</replacetoken>
            <replacevalue>dbcreate="update"</replacevalue>
        </replace>

        <replace file="Application.cfc">
            <replacetoken>logSQL = true</replacetoken>
            <replacevalue>logSQL = false</replacevalue>
        </replace>

        <echo message="Prepping for deployment done." />
    </target>

    <target name="deployToStaging" depends="prepForDeployment">

        <sequential>
            <!--copy the files to a temp directory-->
            <copy todir="${staging}_temp" overwrite="true">
                <!-- -->
            </copy>

            <!-- delete applicaiton files on staging -->
            <delete quiet="true" includeemptydirs="true">
                <fileset dir="${staging}" />
            </delete>

            <!-- copy files from temp dir to application dir -->
            <copy todir="${staging}" overwrite="true">
                <fileset dir="${staging}_temp" />
            </copy>

            <!-- remove temp dir -->
            <delete quiet="true" includeemptydirs="true">
                <fileset dir="${staging}_temp" />
            </delete>
        </sequential>

        <echo message="The files have been copied to staging." />
    </target>

    <macrodef name="runTestDirectory">
        <attribute name="directoryName"/>
        <attribute name="excludes" default=""/>
        <sequential>
            <mxunittask server="${test.server}" port="${test.serverport}" defaultrunner="${test.runner}" outputdir="${test.output.xml}/@{directoryName}" verbose="true" failureproperty="tests.bombed" errorproperty="tests.bombed">
                <directory path="${test.dir.location}/@{directoryName}" recurse="true" packageName="${test.cfcpath}.@{directoryName}" componentPath="${test.cfcpath}.@{directoryName}" excludes="@{excludes}" />
            </mxunittask>
        </sequential>
    </macrodef>

</project>

1 个答案:

答案 0 :(得分:2)

如果您没有告诉Jenkins运行prepForDeploymentdeployToStaging目标,那么它就不会运行它们,就像在命令行上运行Ant一样。

如果您希望运行这些目标,请将它们添加到&#34; Invoke Ant&#34;下的目标列表中。建立步骤。