[解决] - 没有从我系统上的默认位置拾取正确的ant contrib jar。必须在build xml中手动提供路径,如下所示:
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="/usr/share/ant/lib/ant-contrib-1.0b3.jar"/>
</classpath>
</taskdef>
-------------------------------------------
问:我有一个python脚本,通过ant / Jenkins运行,如下所示:
<project name="prjName">
<target name="preRun" description="do something">
....
</target>
<target name="Run" description="Run the python script">
<exec executable="python" failonerror="true">
<arg value="${basedir}/run.py" />
<arg value="something" />
</exec>
</target>
<target name="other1" description="do something">
....
</target>
<target name="other2" description="do something">
....
</target>
</project>
现在这个python脚本运行一个外部工具(web-inject产生一些结果文件)并继续扫描日志中的单词FAIL。一旦发现失败,它就会sys.exit("Error")
因此构建失败但我仍然想要执行目标 - other1。是否有可能通过try-catch?我这样做但是没有用
<macrodef name="test-case">
<sequential>
<trycatch>
<try>
<exec executable="python" failonerror="true">
<arg value="${basedir}/read.py" />
</exec>
</try>
<catch>
<echo>Investigate exceptions in the run!</echo>
</catch>
<finally>
<antcall target="other1" />
</finally>
</trycatch>
</sequential>
</macrodef>
<target name="other1" description="do something">
....
</target>