我在下面进一步执行Ant脚本时遇到以下错误:
不得在顶层使用antcall
我正在使用Jenkins Active Choices插件并将参数传递给Ant脚本。
<project name="svncheckout" default="checkout" basedir=".">
<path id="svnant.classpath">
<pathelement location="/opt/Tomcat/apache-ant-1.9.6/lib/svnClientAdapter.jar"/>
<pathelement location="/opt/Tomcat/apache-ant-1.9.6/lib/ganymed.jar"/>
<pathelement location="/opt/Tomcat/apache-ant-1.9.6/lib/jna.jar"/>
<pathelement location="/opt/Tomcat/apache-ant-1.9.6/lib/svnant.jar"/>
<pathelement location="/opt/Tomcat/apache-ant-1.9.6/lib/svnjavahl.jar"/>
<pathelement location="/opt/Tomcat/apache-ant-1.9.6/lib/svnkit.jar"/>
</path>
<!-- Load the ant contrib lib -->
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="${basedir}/ant-lib/ant-contrib-1.0b3.jar"/>
</classpath>
</taskdef>
<loadproperties srcFile="/opt/Tomcat/apache-ant-1.9.6/chkout.properties"/>
<property name="applist" value="${env.Applns_List}"/>
<foreach list="${applist}"
delimiter=","
target="checkout"
param="appl.id" />
<typedef resource="org/tigris/subversion/svnant/svnantlib.xml" />
<svnSetting
svnkit="true"
javahl="false"
username="xxx"
password="xxx"
id="svn.settings"/>
<target name="checkout" description="checkout code">
<forEach property="application" list="${applist}" delimiter=",">
<sequential>
<svn refid="svn.settings" >
<checkout url="${application}.url"
destPath="/opt/tibco/DeploymentFramework/checkout/" />
</svn>
</sequential>
</forEach>
</target>
</project>
请帮我解决这个问题。
答案 0 :(得分:0)
Ant-Contrib <foreach>
task不能在Ant脚本的顶层使用。
相反,<foreach>
必须位于<target>
...
<!-- Change the default target from "checkout" to "run" -->
<project name="svncheckout" default="run">
<target name="run">
<!-- This <foreach> is now inside of a <target> -->
<foreach list="${applist}"
delimiter=","
target="checkout"
param="appl.id" />
</target>
<target name="checkout">
<echo>appl.id is: ${appl.id}</echo>
</target>
</project>