How to reference Chold actions/steps info in mail notification template

Hello.

I have created Project with structure like this:
First simple step
Second composite step
First child step
Second child step
Send an email step

In “Send an email step” i use templates from this article: https://octopus.com/docs/deployment-examples/email-notifications#email-template-examples
It iterates Actions and Steps without childs, and resulting mail body is like:

    Deployment process

    The deployment included the following actions:

        Send mail notification
        First simple step
        Second composite step

    Task summary

        First simple step — Succeeded
        Second composite step — Succeeded
        Send an email step — Running
        Acquire Packages — Succeeded
        Apply Tentacle Retention Policy — Succeeded

Is there a way to write child steps info in mail body like it is written for parent steps?

Hi Koyot,

Thanks for getting in touch! Child steps are referenced in the same way as standalone steps (i.e. Octopus.Action[ChildStepName].Name) so this template should be printing out each child step name. When testing it in my local instance, I get the expected result.

Deployment process:

Email:

I’d like to dig into it a bit more to see if there’s any specific reason why it’s not giving you the same result. Which Octopus server version are you currently running?
Are you using the exact template as shown in the doc page you’ve linked to? If not, could you provide the full email body you’re using?

I look forward to hearing back and getting to the bottom of this one!

Best regards,

Kenny

Hi, Kenny.
I have used Octopus v2018.7.13
My fault, i have seen at “Task summary” template, not “Deployment actions template”.
The template i have used is: (Redirecting to https://octopus.com/docs/projects/built-in-step-templates/email-notifications)

<h3>Task summary</h3>
<ol>
#{each step in Octopus.Step}
  #{if step.Status.Code}
    <li>#{step | HtmlEscape} &mdash; <strong>#{step.Status.Code}</strong>
    #{if step.Status.Error}
      <pre>#{step.Status.Error | HtmlEscape}</pre>
      <pre>#{step.Status.ErrorDetail | HtmlEscape}</pre>
    #{/if}  
    </li>
  #{/if}
#{/each}
</ol>

And child steps are not printed in this case.

Hi Koyot,

Thanks for following up and clarifying that! Child steps are only available as Octopus.Action parameters, whereas Octopus.Step return only the top level steps (parent steps or steps that don’t have child steps). This means that you’d have to iterate over Octopus.Action to have it include child steps. Giving this a test, I’ve been able to get somewhat close to what this template is doing, and I’d like to hear if this is an acceptable approach for you. :slight_smile:

In my email step, I have the following body:

<h3>Task summary</h3>
<ol>
#{each action in Octopus.Action}
    <li>#{action| HtmlEscape}
#{if action.Status.Code} 
&mdash; <strong>#{action.Status.Code}</strong>
#{/if}
    </li>
#{/each}
</ol>

Which results in the following email (when I purposefully failed a step).

I hope this helps! Let me know what you think or if you have any further questions. :slight_smile:

Best regards,

Kenny

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.