I've octopus variables under "Library" -> "Variable Sets" variables with names
1. DatabaseExceptions
2. ReportsExceptions
3. ApplicationExceptions
And I've setup of my project "Deployment process" in octopus as steps
1. Database
2. Reports
3. Application
4. Send Email
The above variable are set with exceptions by using 'PowerShell' scripts that are invoked using predeploy.ps1 of the particular step on exceptions in scripts.
At the last step(Send Email) I was trying to send email with the information in exception variables by checking if particular variable has information in it.
I'm doing this in the send Email step body by checking the check box("Body as HTML")
<h2>Deployment Steps</h2>
<ol>
#{each step in Octopus.Step}
#{if step.Status.Code}
<li>#{step | HtmlEscape} —
#{if Step.Name == "Database"}
#{if Octopus.Action[Database].Output.DatabaseExceptions}
<pre>#{Octopus.Action[Database].Output.DatabaseExceptions}</pre>
#{/if}
#{/if}
#{if Step.Name == "Reports"}
#{if Octopus.Action[Reports].Output.ReportsExceptions}
<pre>#{Octopus.Action[Reports].Output.ReportsExceptions}</pre>
#{/if}
#{/if}
#{if Step.Name == "Application"}
#{if Octopus.Action[Application].Output.ApplicationExceptions}
<pre>#{Octopus.Action[Application].Output.ApplicationExceptions}</pre>
#{/if}
#{/if}
</li>
#{/if}
#{/each}
</ol>
The Database and Reports scripts has errors and my output looks like below which is correct as expected
Deployment Steps
1. Database — Exception on processing DB scripts - info:...
2. Reports — Exception on processing Reports - info:...
3. Application
4. Send Email
And my Question:
Is it possible to do something as below as my step name and starting of my variable name are same
<h2>Deployment Steps</h2>
<ol>
#{each step in Octopus.Step}
#{if step.Status.Code}
<li>#{step | HtmlEscape} —
#{if Octopus.Action[#{step.Name}].Output.#{step.Name}Exceptions}
<pre>#{Octopus.Action[#{step.Name}].Output.#{step.Name}Exceptions}</pre>
#{/if}
</li>
#{/if}
#{/each}
</ol>