How can I exist a <foreach> loop?
I've tried the following:
<foreach ... ... ... unless="${needs.build}">
and also:
<do unless="${needs.build}">
But the loops keep running through all items.
Basically, I'm trying to loop through a bunch of Subversion URLs, and detect if a build is needed based on last commit revision vs my last build revision. But I can't get the script to exit the <foreach> when it finds that the first one is true.
I'll paste the full target below...
Thanks,
Mike
<target name="isbuildneeded" description="Check if a build is needed script to see if our build is up to date already."
verbose="true">
<foreach item="String" in="${project.svn.path}" property="svn.path" verbose="true" delim=" " trim="Both">
<do unless="${build.needed}">
<exec program="svn.exe" commandline="info --xml ${svn.path}" output="${infolog}" />
<do unless="${build.needed}">
<exec program="svn.exe" commandline="info --xml ${svn.path}" output="${infolog}" />
<xmlpeek xpath="/info/entry[1]/@revision" file="${infolog}" property="reposrev" />
<xmlpeek xpath="//commit/@revision" file="${infolog}" property="maxcommitrev" />
<echo message="++++++++++++++++++++++++++++++++++++++++++++++++" />
<echo message="Max //comit/@revision: ${maxcommitrev}" />
<echo message="++++++++++++++++++++++++++++++++++++++++++++++++" />
<xmlpeek xpath="//commit/@revision" file="${infolog}" property="maxcommitrev" />
<echo message="++++++++++++++++++++++++++++++++++++++++++++++++" />
<echo message="Max //comit/@revision: ${maxcommitrev}" />
<echo message="++++++++++++++++++++++++++++++++++++++++++++++++" />
<!-- Use ENV variables to return values -->
<setenv name="ReposRev" value="${reposrev}" />
<setenv name="maxcommitrev" value="${maxcommitrev}" />
<setenv name="ReposRev" value="${reposrev}" />
<setenv name="maxcommitrev" value="${maxcommitrev}" />
<!-- check automated.build.log for build needed statement and set VAR to true-->
<if test="${environment::variable-exists('maxcommitrev')}">
<property name="MaxCommitRev" value="${environment::get-variable('maxcommitrev')}" />
<property name="ReposRev" value="${environment::get-variable('ReposRev')}" />
</if>
<property name="MaxCommitRev" value="${environment::get-variable('maxcommitrev')}" />
<property name="ReposRev" value="${environment::get-variable('ReposRev')}" />
</if>
<loadfile file="${lastbuild.version.file}" property="LastBuildRev">
<filterchain>
<replacestring from="SVNREVISION: " to="" />
</filterchain>
</loadfile>
<if test="${LastBuildRev < MaxCommitRev}">
<echo append="true" file="automated.build.log" message="${datetime::now()} - ${project.build.path}: Needs a Build" />
<property name="build.needed" value="true" dynamic="true"/>
</if>
<ifnot test="${LastBuildRev < MaxCommitRev}">
<echo append="true" file="automated.build.log" message="${datetime::now()} - ${project.build.path}: No Build needed." />
<property name="build.needed" value="false" dynamic="true"/>
</ifnot>
</do>
<echo message="Build needed: ${build.needed}" />
</foreach>
<filterchain>
<replacestring from="SVNREVISION: " to="" />
</filterchain>
</loadfile>
<if test="${LastBuildRev < MaxCommitRev}">
<echo append="true" file="automated.build.log" message="${datetime::now()} - ${project.build.path}: Needs a Build" />
<property name="build.needed" value="true" dynamic="true"/>
</if>
<ifnot test="${LastBuildRev < MaxCommitRev}">
<echo append="true" file="automated.build.log" message="${datetime::now()} - ${project.build.path}: No Build needed." />
<property name="build.needed" value="false" dynamic="true"/>
</ifnot>
</do>
<echo message="Build needed: ${build.needed}" />
</foreach>
</target>
Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls. Great rates starting at 1ยข/min.
------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________ NAnt-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/nant-users
