Powershell - root directory path

markb's Avatar


10 Nov, 2017 12:20 AM

Part of our front end build process creates a JSON file in the site root. During deployment I need to read that file, but trying these variables returns empty strings. I'm trying to run my script before the site is deployed in a separate "run a script" step

Write-Host $OctopusParameters['Octopus.Action[SIteName].Package.InstallationDirectoryPath'] 
# empty string

Write-Host $OctopusParameters['Octopus.Action.Package.CustomInstallationDirectory']
# empty string

Write-Host $OctopusParameters['Octopus.Action[SiteName].Package.CustomInstallationDirectory']
# C:\site\Web (I don't know how this is set or why it returns this value)

Write-Host $OctopusParameters['OctopusOriginalPackageDirectoryPath']
# empty string

Is there some variable that will return the current site's root directory - the site that I'm deploying? Am I trying to access this directory too early in the process? If so at what point can I access the site's root directory?


  1. 1 Posted by markb on 10 Nov, 2017 07:46 PM

    markb's Avatar

    To follow up, if I move this script step after the Deployment then using InstallationDirectoryPath gets the correct path. Is there any way I can access that path before the deployment step?

    I also tried checking the box for "Wait for packages to be downloaded before running" but that didn't help.


  2. 2 Posted by markb on 10 Nov, 2017 08:32 PM

    markb's Avatar

    More attempts. It seems like if the first step is a "Run a Script" step almost none of these variables return anything. I'm just trying to get the current directory where all my files are that are going to get deployed in the next step

    Write-Output ("FilePath: " + $FilePath)
    # c:\Logs\Site.Services.dev
    # empty string
    # C:\Program Files\Octopus Deploy 30\Tentacle
    # Releases-109793
    # Releases-109793
    # empty string
    # empty string

    Thanks again!

  3. 3 Posted by markb on 10 Nov, 2017 10:06 PM

    markb's Avatar

    I got it! This is the correct path I misread the deployment step and thought it should be going to a different location.


  4. Support Staff 4 Posted by Reece Walsh on 13 Nov, 2017 03:37 AM

    Reece Walsh's Avatar

    Hi Mark,

    Thank you for contacting Octopus Deploy support in regards to this query,

    It's great to hear you have a solution in-hand, I appreciate you taking the time to update the ticket with your breakdown on the issue.

    If you require any assistance in the future please do not hesitate to reach out :)

    Kind Regards,


  5. Paul Stovell closed this discussion on 04 Mar, 2018 10:15 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac