#{Octopus.Machine.Name} is not getting substituted in Send Email Step


For some reason the system variable #{Octopus.Machine.Name} is not getting substituted in the Send Email step.

It’s successfully being substituted in other steps (for example my custom Post Announcement to Yammer step).

It looks like a similar issue was reported here but I cannot see any resolution

ServerTasks-1462.log.txt (119 KB)

Looks like it has an issue with any Octopus.Machine variable as the Email step also fails to substitute Octopus.Machine.Hostname.

Octopus.Machine.Hostname is successfully substituted in other tasks which also run on Octopus Server.


Thanks for getting in touch! And thank you for attaching the log! However, I will need to grab a copy of your deployment log with the variable logging enabled. The following link has instructions on how to enable the variable logging. This will print out any variables used in the deployment and how they are evaluated. It will give me a better idea of what could be going on here.

Looking forward to hearing from you.

Best regards,

Thanks Daniel, the log file is attached.

I look forward to hearing back from you soon.

ServerTasks-1778.log.txt (4 MB)


Thanks for getting back with those logs. I had a look and can see that you are using the following as your email subject.

Announcement: #{Octopus.Project.Name} #{Octopus.Release.Number} deployed to #{Octopus.Deployment.Tenant.Name}.#{Octopus.Environment.Name}.#{Octopus.Machine.Name} - #{if Octopus.Deployment.Error} Failed #{/if} #{unless Octopus.Deployment.Error} Succeeded #{/unless}

The variable substitution logic you are using here is not available inside the email subject. Only basic replacement of variables. Would you be able to test with just #{Octopus.Machine.Name} On its own, and let me know how it goes?

Looking forward to hearing from you.

Best regards,

Thanks Daniel.

I changed the subject to just #{Octopus.Machine.Name} and it still fails. The email I receive still has “#{Octopus.Machine.Name}” in the subject.

By the way the substitution logic actually seems to be working. So when I use the following

Announcement: #{Octopus.Project.Name} #{Octopus.Release.Number} deployed to #{Octopus.Deployment.Tenant.Name}.#{Octopus.Environment.Name}.#{Octopus.Machine.Name} - #{if Octopus.Deployment.Error} Failed #{/if} #{unless Octopus.Deployment.Error} Succeeded #{/unless}

The subject of the email I receive when the release fails is

Announcement: e5Anywhere 3.7.7875.1 deployed to e5Workflow.Test.#{Octopus.Machine.Name} - Failed

And when the release succeeds I receive

Announcement: e5Anywhere 3.7.7875.1 deployed to e5Workflow.Test.#{Octopus.Machine.Name} - Succeeded


Sorry for the bad information there! I was mistaken. However, I think I just found the issue. From your most recent log file:

                    |   == Success: Step 22: Send Announcement Email ==
14:42:42   Verbose  |     Send Announcement Email completed
                    |     Success: Octopus Server
14:42:41   Verbose  |       Octopus Server version: 3.17.6+Branch.master.Sha.dcdc0afc5710895f4bd79567e4eea56e584cfb7d
14:42:41   Verbose  |       Environment Information:
                    |       OperatingSystem: Microsoft Windows NT 10.0.14393.0
                    |       OsBitVersion: x64
                    |       Is64BitProcess: True
                    |       CurrentUser: DATARACT2\svc_e5admin
                    |       MachineName: PRDBUILD
                    |       ProcessorCount: 8
                    |       CurrentDirectory: C:\Windows\system32
                    |       TempDirectory: C:\Users\svc_e5admin\AppData\Local\Temp\
                    |       HostProcessName: Octopus.Server
                    |       PID: 3000
14:42:41   Verbose  |       Email parameters:
14:42:41   Verbose  |       Subject: Announcement: e5Anywhere Release 3.7.7741.1 deployed to Test #{Octopus.Machine.Name} -   Succeeded
14:42:41   Verbose  |       To: pnolan@e5workflow.com
14:42:41   Verbose  |       Cc:
14:42:41   Verbose  |       Bcc:
14:42:41   Verbose  |       Sending email message...
14:42:42   Info     |       Email sent!
14:42:42   Verbose  |       Successfully finished Send Announcement Email on the Octopus Server


Success: Octopus Server

It looks like your email step is being run directly on the Octopus server and not a specific target. This system variable is only able to resolve to the machine name of the step it is currently running on. You should be able to remedy this by creating an Output Variable inside the step, then calling it in the subject. See below:

Inside the step you wish to capture the machine name of:

Set-OctopusVariable -name "emailMachine" -value #{Octopus.Machine.Name}

Then you can call the variable in your email subject with: (Note the [StepA] must contain the step you created the output variable in.)


Could you try the above and let me know if it helps you resolve your issue?

Again, sorry for the misinformation in my previous response! I hope the above helps you get this working. :slight_smile:

Best regards,

Thanks Daniel that worked!

I actually considered this but I ruled it out as I’m also using #{Octopus.Machine.Name} in my custom step to post an announcement to yammer. It’s also been configured to run on the Octopus Server and it works fine. So that’s a bit confusing :frowning: