Index based loop

Hi

I’m trying to get a list of deployed packages into an email at the end of a deployment.

Is there a way of looping through an index based collection, something like this:

#{for i = 0; i < = #{Octopus.Steps.Count}; i++ }
#{Octopus.Steps[i].Package.NuGetPackageId}
#{Octopus.Steps[i].Package.NuGetPackageVersion}
#{/for}

I haven’t been able to find the correct syntax …

Thanks
Ken

Hi Ken,

Thanks for getting in touch. Perhaps the #{each} syntax will suit your situation?

Take a look at the example provided in http://docs.octopusdeploy.com/display/OD/Email+notifications

<p>The deployment included the following actions:</p>
<ul>
  #{each action in Octopus.Action}
    <li><strong>#{action.Name}</strong> #{if action.Package.NuGetPackageId}&mdash; <a href="http://nuget.org/packages/#{action.Package.NuGetPackageId}">#{action.Package.NuGetPackageId}</a> <em>version #{action.Package.NuGetPackageVersion}#{/if}</em></li>
  #{/each}
</ul>

If I’ve missed the point of your question, please let me know more specifically what you’re trying to achieve and I’ll be happy to help you further.

Hope that helps!
Mike

Hi Michael

Yep that seems to work –thanks!

I based my enquiry on a 2013 post by Paul Stovell that seemed to suggest that doing this needed indexes, but I guess that might be a bit obsolete :slight_smile:

Great product by the way. I’m trialling Octopus after months of frustration using Release Management, and am very pleased with it.

[cid:image001.png@01D0C086.F5632310]

Ken Arthur
Senior Software Engineer
Direct: +61 7 3177 4754
Email: Ken.Arthur@nextdc.com

NEXTDC (ASX: NXT)
www.nextdc.com

image001.png

Hi Ken,

Thanks for getting back to us. I’m glad that worked our for you!

Regards,
Mike