$env:computername

When constructing an email for a deployment, I want to indicate the computer, but I’m doing it wrong. This is what I’m getting:

Project Link /app#/projects/projects-1
Release Link http://$env:computername//app#/releases/releases-9567
Deployment http://$($env:COMPUTERNAME)/app#/deployments/deployments-9631
Hostname $($env:COMPUTERNAME)

Can you tell me what I’m doing wrong?

Thank you.

Here’s the source of the email body that generates the previous message:

Try using the token replacement syntax.
#{env:COMPUTERNAME}

1 Like

The correct way to reference the octopus server is with this variable:

Octopus.Web.BaseUrl

You can find a full description of the system variables that are automatically put in for you here: https://octopus.com/docs/deployment-process/variables/system-variables

Cheers,
T3

1 Like

Unfortunately for me, my version doesn’t support Octopus.Web.BaseUrl. And #{env:COMPUTERNAME} doesn’t appear to work either.

Regarding Octopus.Web.BaseUrl, the docs say

this value will likely not be suitable for use in referring to the server from a client perspective, e.g. in email templates etc.

@Factotum what version of Octopus Server are you running?

I don’t think #{env:COMPUTERNAME} should work. Since the #{} system is for accessing Octopus provided variables.

Your Release link having the $env:computername in it is a parsing error. I’m guessing you are running this on the Octopus Server as a powershell script?

If so, do it this way
$myHostname = $env:ComputerName
Http://$myHostname/

Doing it the other way causes it to try and solve the release link as an HTTP first… don’t do to that. If you are generating this in powershell and in a STRING having this issue then you can try this

$releaseLink = (“http://” + $env:Computername + “/…”)
And that should kick out what you are looking for.

Now, Since I looked at the the fact you are doing this in email body.

Break apart your process into two steps. The first one being a powershell script that just gathers data for you on what the ‘Project Link’ and others are going to be.

THen use the Set-OctopusVariable -Name ProjectLink -Value $fullProjectLink

On the email step, just use the #{Octopus.Action[].Output.ProjectLink}

That will properly parse the output variable from a previous octopus step.

Hope that helps.

-T3