Iterate

Description

Iterates over a collection of objects.

Parameters

Attribute Description Required
collection The collection of objects to iterate over. This will be a property, but don't enclose it in ${}. Yes
target The target which will be called for each object in the collection. Yes
param The name used to reference the object in the target. Yes
failOnError If false, the build will continue execution when an error occurs. Otherwise, the build will fail. No. Default is true.
clearCache If true, cached assets will be cleared before this task is executed. No. Default is false.

Example

Print the names of assets obtained through a search.

<target name="testIterate">
    <propertyHelper />
    <search server="ramServer" query="test" id="searchResults" />
    <iterate collection="searchResults" param="asset" target="printAssetName" />
</target>
	
<target name="printAssetName">
    <propertyHelper />
    <echo message="Name: ${asset.name}" />
</target>

Print the names of the owners of a particular asset.

<target name="testIterate">
    <propertyHelper />
    <asset server="ramServer" id="asset" guid="64D3B30E-C8DF-5800-3F69-49BAF2D8A438" version="1.0" />
    <iterate collection="asset.owners" param="owner" target="printOwnerName" />
</target>

<target name="printOwnerName">
    <propertyHelper />
    <echo message="Name: ${owner.name}" />
</target>