Getting the home directory of an agent via Powershell

Hi there,

I’m trying to retrieve the home directory of the tentacle (i.e. “C:\Octopus”) via Powershell. This is necessary because, during deployment, we want to create directories within this directory. Hard coding the path in the script is not an option since it can differ between machines, neither is passing it as a variable.

I’ve checked the official documentation for system variables on: https://octopus.com/docs/deployment-process/variables/system-variables
I cannot find what I’m looking for however.

I’ve tried using the system variable Octopus.Tentacle.Agent.ApplicationDirectoryPath because this returns the path in which Octopus installs the packages (i.e. "C:\Octopus\Applications).
I could get the necessary substring by truncating the value of this variable, but this seems cumbersome.

Is there a system variable I’m somehow missing, or is this simply not possible?

Thank you,
Josh

Hi Josh,

Thanks for getting in touch! Unfortunately we do not have a variable to return exactly what you are after. I think the best current option is to truncate the returned value as you mentioned.

The only other option I could recommend is to use variables which are scoped to different targets.

Let me know if you have any further questions here.

Best regards,
Daniel

Hi Daniel,

Thanks for the response. Setting up scoped variables for each deployment target would be too much hassle for us right now. So I’ll go the truncating way.

Cheers,
Josh