Newbie help with system variables

Hello,

This is my first foray into octopus deploy so please be gentle :smiley:

I tried creating a simple powershell step that checks to see if a directory exists and creates that directory. I tried using System.Project.Name variable listed here: http://docs.octopusdeploy.com/display/OD/System+variables by doing the following:

$sitedir="c:\inetpub$Octopus.Project.Name"
if (!(test-path -path $sitedir)) { new-item -item directory -path $sitedir}

It creates the folder successfully, however the directory name ends up as C:\inetpub.Project.Name
I tried using some of the other system variables and they don’t’ seem to work either :frowning:

I’m obviously missing something here and any help would be greatly appreciated!

I’m running Octopus Deploy 2.4.7/85 and latest version of tentacle.

Thanks in advance,

Larry

oops - sorry it creates the directory name as:
c:\inetpub.Project.Name

hmm - seems like the discussion site is escaping the “” after inetpub.
3rd try:

C:\inetpub\.Project.Name

Duh, close this ticket. It took a bit of reading through the comments on the documentation and also looking through the raw output with the variables OctopusPrintEvaluatedVariables and OctopusPrintVariables enabled before I understood what was going on (sort of).

I created a new simple project test.

  1. I wasn’t calling the system variables correctly. You have to assign what you’re calling to a variable --i.e. $var = $OctopusParameters[“systemvariable”]

  2. It looks like Octopus is trying to run a powershellscript that doesn’t get escaped
    properly if you place a nested variable inline - note missing single quite in the raw output.
    17:16:47 Verbose | - [Octopus.Step[0].Script.ScriptBody] = '$sitedir=“c:\inetpub$OctopusParameters[“Octopus.Project.Name”]”

The only way I could get this working was doing the following:
$sitedir=“c:\inetpub” + $OctopusParameters[‘Octopus.Project.Name’]
if (!(test-path -path $sitedir)) { new-item -item directory -path $sitedir}

If someone has an easier way to do this, please let me know.
Anyway hope this helps someone else that is just getting started…,

Thanks,
Larry

Hi Larry,

Thanks for your post!

An alternative solution would be the following:

$projectName = $OctopusParameters["Octopus.Project.Name"]
$sitdir = "c:\inetpub\$projectName"

Hope this helps!

Vanessa