Email template - sorting actions

Hi all,
I’m working on revising our email template after it was noticed that the steps “appeared” out of order when the email was being reviewed after a failure. It appears that when the step gets the list of actions it puts the current step at the top of the list and any prior steps get rolled to the bottom of the list. I tried getting around that by adding the Step number in front of the Step name, but I can’t get the child steps to show their step number. Is there a good way to sort actions in their correct order as they appear on the Process page? If not, is there a way to get the child action step number?

Here is an example of how the emails come out (using our test project and aborting the manual intervention step).

  • 2 - Email Deployment Created - Succeeded
  • 4 - Email Deployment Proceed - Abandoned
  • 5 - Deploy - Abandoned — NugetPackageId version 1.0.80-Dev
  • #{Octopus.Step[#{action.Name}].Number} - Child Step -
  • 6 - Send Deployment RESULTS Email - Running
  • 1 - Get Current Date - Succeeded
  • 3 - AcknowledgeDeploy - Failed The user did not complete the manual step Octopus.Server.Orchestration.Targets.Tasks.ActivityFailedException: The user did not complete the manual step at Octopus.Server.Orchestration.ServerTasks.Deploy.Steps.Manual.ManualActionHandler.ThrowOnUserAbort(Interruption interruption) at Octopus.Server.Orchestration.ServerTasks.Deploy.Steps.Manual.ManualActionHandler.Complete(ActionCommand command, String interruptionId) at Octopus.Server.Orchestration.ServerTasks.Deploy.DeploymentTaskController.ResumeAnyPausedSteps()

Here is what I’m using for the “deployment steps” section of the email:

<ul> #{each action in Octopus.Action} <li><strong>#{Octopus.Step[#{action.Name}].Number} - #{action.Name} - #{if Octopus.Step[#{action.Name}].Status.Code}#{Octopus.Step[#{action.Name}].Status.Code}#{/if} #{if Octopus.Step[#{action.Name}].Status.Error}#{Octopus.Step[#{action.Name}].Status.Error}#{/if} #{if Octopus.Step[#{action.Name}].Status.ErrorDetail}#{Octopus.Step[#{action.Name}].Status.ErrorDetail}#{/if}</strong> #{if action.Package.NuGetPackageId}&mdash; #{action.Package.NuGetPackageId} <em>version #{action.Package.NuGetPackageVersion}#{/if}</em> #{/each} </ul>

Hi Josh,

Thanks for getting in touch! Firstly, child steps are only available as Octopus.Action parameters, whereas Octopus.Step are only top level steps (parent steps or steps that don’t have child steps). Modifying this to the following will write the child step numbers as decimal delimited (i.e. 1.1, 1.2, 1.3 …).

<li><strong>#{Octopus.Action[#{action.Name}].Number} - #{action.Name} - #{if Octopus.Step[#{action.Name}].Status.Code}#{Octopus.Step[#{action.Name}].Status.Code}#{/if} #{if Octopus.Step[#{action.Name}].Status.Error}#{Octopus.Step[#{action.Name}].Status.Error}#{/if} #{if Octopus.Step[#{action.Name}].Status.ErrorDetail}#{Octopus.Step[#{action.Name}].Status.ErrorDetail}#{/if}</strong> #{if action.Package.NuGetPackageId}&mdash; #{action.Package.NuGetPackageId} <em>version #{action.Package.NuGetPackageVersion}#{/if}</em>
#{/each}
</ul>

Which then results in the email looking like this:

The currently running email step is placed at the top, though the ordering is correct beneath it, which seems a little better than the seemingly random order you’re experiencing. I’m currently running this on 2018.8.12 in my local instance - which version are you currently running?

With my testing I haven’t been able to come to a way to push this step down to the bottom, other than listing out the steps individually and not using each (which isn’t a good solution). Does this help for the time being, however?

I look forward to hearing back!

Best regards,

Kenny

Thanks Kenny, your changes worked for allowing the numbers to show up correctly. That should work for us. The order was just a nice to have if it was there, but now that we have the numbers ahead of the step name correctly we should be good.

P.S. we’re on 2018.6.4 at the moment.

Hi Josh,

Thanks for following up and letting me know the step numbers are now showing up correctly. :slight_smile: Don’t hesitate to reach out if you have any further questions in the future.

Best regards,

Kenny

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