Variable Substition Working in Email Subject but not Body


I’m trying to send an email at the end of the Octopus Deploy process to indicate the success or failure of the deployment.

The subject consists of:

#{Octopus.Project.Name} Deploy to #{Octopus.Environment.Name} of release #{Octopus.Release.Number} - #{unless Octopus.Deployment.Error}Successful#{/unless}#{if Octopus.Deployment.Error}Failure#{/if}

and is working correctly. However, the Body of the email begins with the same line, but Octopus sends the email out with the string still containing the variable names “#{Octopus.Project.Name} Deploy to #{Octopus.Environment.Name}”…

I’ve read about limitations with regards to variables one can access from the email process, but I’d assumed that if I can use a variable in the Subject, I could also use it in the email Body.

What am I missing here?

Hi Greg,

Thanks for getting in touch. This is an interesting one. The variables should definitely be replaced in the email Body. I’ve setup a test and cannot reproduce this problem, so we’ll need some more information to help track down what’s happening.

Could you please send through the specific version of Octopus you’re running (depending on the version, this will either be in the footer or in the top-right help menu).

Can you also please provide screenshots showing your Email step, clearly showing the Subject and Body fields.


Hi Mark,

Thanks for getting back to me. I’m running Octopus version 3.3.0

Screenshot, attached.

Looks like the attachment didn’t attach last time.

Hi Greg,

If I look closely at your screenshot, I can see a space in the body’s closing “unless” tag. Eg. #{unless }

That space is causing the variable substitution to fail. Remove that space and all will start working :slight_smile:


That did it! Thanks Mark!

As a side note, it would’ve been helpful to have some kind of error or warning message in the Octopus logs about the syntax error.


Hi Greg,

Glad that solved it :slight_smile:

Regarding error logs, it gets tricky because some customers have non-Octopus configurations that use their own variable substitution, so we have to tread carefully when reporting that variable syntax may be broken vs ignored in user-generated scripts. In this case, our decision to leave the variables as un-replaced is how we show it as an error.