I’m trying to implement an Email Notification step that includes the list of deployment steps and whether or not they are pending or skipped by the user. This works perfectly fine in one project but then is sorted incorrectly in another project. The email template is shared through a variable so it’s the same exact code building the email body. Any know issues with sorting or any tips to help mitigate this?
Here’s an example of the incorrect sorting from the email body.
I’ve been playing around with this today and haven’t found a super elegant way to solve this. The issue is that “Octopus.Action” is a Collection (Dictionary with HashTable) which doesn’t maintain order.
I’ve modified the script you provided so that it will check the Action.Number before writing the output, and can be extended for however many Actions you’d like outputted. I would prefer to do this more gracefully but it does work based on my tests!
I’ve started some internal discussion about getting Octostache extended so that this is easier to achieve but that should at least get them ordered in the meantime.
Feel free to let me know if you have any questions!
Uhh yeah this looks horribly inefficient and painful. One of my projects has over 60 steps not including child steps, not to mention that projects change over time and trying to keep up with this would not scale.
I agree it’s not a great solution and there is definitely a better approach to be found here. I’ll keep diving into this and keep you posted when I’ve come up with a better workaround.
I have finally managed to get this working for any number of steps! The process does require an additional step to create an Output variable which is the list of steps in order.
The following script is defined in a Run a Script step which outputs a JSON string with the required details in order.