What we want to do is send a email to the development team whenever a deployment fails. I put the following script together that runs as the last step and what is does in checks the variable $OctopusParameters[‘Octopus.Deployment.Error’] and if it has a value sends the email. The problem I’m having is getting the error detail into the email. I thought that this variable would contain that detail but its always null as far as I can tell. $OctopusParameters[‘Octopus.Deployment.ErrorDetail’]. Is there some other way I should go about getting the error details for the step that failed? Thanks for the help!
$recipients = $OctopusParameters[‘recipients’]
$subject = $OctopusParameters[‘Octopus.Project.Name’] + " Failed on: " + $OctopusParameters[‘Octopus.Environment.Name’]
$deploymentError = $OctopusParameters[‘Octopus.Deployment.Error’]
$emailBody = $OctopusParameters['Octopus.Deployment.ErrorDetail']
$pwd = ConvertTo-SecureString $smtpPassword -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential fusiontech,$pwd
send-mailmessage -from “Jane Doe JaneDoe@ACME.com” -to $recipients -subject $subject -body $deploymentError -priority High -smtpServer “smtp” -Credential $cred -Port “8181”