Email template

Hi,

I am trying to figure out how I can capture a log of below step in email body

Step 4: VerifyDeployment
DeploymentSucceeded

Thursday, January 7, 2016 4:10:16 AM
The solution was successfully deployed.

I have looked through http://docs.octopusdeploy.com/display/OD/Email+notifications, but unsure what variable to use and how to use it

Hi Praveen,

Thanks for getting in touch! Unfortunately we cannot know that a deployment is successful until after it finishes, and if the last step is to send an email, then the deployment could still fail on sending the email, so there is no status we can give during the deployment.

We do have a few things that you could use. Octopus.Deployment.Error updates with an error if a step fails, by the email step you could assume that if its empty, the deployment hasn’t failed yet! Sample template would be:

#{if Octopus.Deployment.Error} Deployment failed with error: #{Octopus.Deployment.Error}#{/if}
#{unless Octopus.Deployment.Error}So far the deployment was successful!#{/unless}

Also you can have each step print its success up to that point:

#{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}

Hopefully with that information you will have a good idea of how the deployment went.

Hope that helps!
Vanessa

Hi Vanessa,

Thanks for your reply. I am already using that template you pasted below and it displays the status of the deployment beautifully. But what I would also like to do is display the below task log captured by Octopus in the email body.

I think #{Octopus.Action[VerifyDeployment].Script.ScriptBody} will just display the powershell commands in the script and not the log. Is it possible to display the log below in the email body?

[cid:image001.png@01D14D17.3C221C30]

Thanks and regards,
Praveen

Hi Praveen,

Sorry I thought it was part of your final step in a deployment, not output from a PowerShell. There is no way currently. We do not capture the output of the PowerShell scripts only display it and put it into the logs. It isn’t available during the deployment. You could link back to the deployment log from the email but that is probably about it.

This sounds like a good suggestion for our UserVoice site though!

Vanessa

Hi Vanessa,

Thanks for your reply.

Regards,
Praveen