Reference Project variables in powershell scripts after 2018.~ upgrade

We are currently running v.3.17.4. I have setup a sandbox server testing out v.2018.3.4.
Using the octopus.migrator.exe, tool I have recreated several deployment projects and am noticing some failures referencing variables via PowerShell on the new version.

Example 1:
My project has a project-specific variable called ‘DirAgl’
Then Step 1 runs the following powershell:

$AGLName = $OctopusParameters[‘DirAgl’]
Write-Host “Lets determine the primary AGL Node for:” $AGLName
$activeNodeName = invoke-sqlcmd -ServerInstance $AGLName -query “Select ServerProperty(‘ComputerNamePhysicalNetBIOS’)” | select -expand Column1
$activeNodeHostName = $activeNodeName+"."+$OctopusParameters[‘Domain.Hostname’]
Set-OctopusVariable -name “ActiveDirNode” -value $activeNodeHostName
Write-Host “The primary AGL Node is:” $activeNodeHostName

When I run this in v.2018.3.4, the project specific variable does not get pulled in to the script and it fails. However this exact same scenario works just fine in v.3.17.4.

Log:
ServerTasks-2217.log.txt (8.3 KB)

Example 2:
I have a Transfer Package step where the Transfer Path =
#{Octopus.Tentacle.Agent.ApplicationDirectoryPath}#{Octopus.Action.Package.PackageId}

For a given package named: ‘LogsToElastic.Lambda.1.0.359.nupkg
the transfer step is creating:
'C:\Octopus\DevDeploy\Files\LogsToElastic.Lambda@S1.0.359@5DE1861E0FB7614FAC6D7980C1D795A8.nupkg’

Thus my subsequent step is referencing ‘package.packageID’ is failing:

$path = $OctopusParameters[‘Octopus.Action[Copy Package to Agent].Package.TransferPath’]
$packageId = $OctopusParameters[‘Octopus.Action[Copy Package to Agent].Package.PackageId’]
$packageVersion = $OctopusParameters[‘Octopus.Action[Copy Package to Agent].Package.PackageVersion’]
$nuGetFileName = “$path$packageId.$packageVersion.nupkg”
$zipFileName = “$path$packageId.$packageVersion.zip”

Copy-Item -Path “$nuGetFileName” -Destination “$zipFileName”

Log: ServerTasks-2490.log.txt (12.8 KB)

I would like to re-iterate that the code running on both versions is literally copy-pasta from one to the other and fails only on the newer version.

Hi,

My apologies for the delay in getting back to you.

Could you add the variable OctopusPrintEvaluatedVariables with a value of True to your 2018.3.4 instance and create and run another deployment and send me the raw deployment log of that deployment please.

This should help us figure out why the variable isn’t being evaluated properly.

Thank you and best regards,
Henrik

Hello Henrik -

Thanks for your response. We can actually close this issue. On the first example my project variable was scoped wrong. On the second we found some changed Octopus system variables germane to the Transfer Packages step and were able to work through our issue.

Thanks again,

Ryan

Hi Ryan,

Great to hear that you got it all sorted!

Thank you and best regards,
Henrik

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.