Thanks for clarifying that! After some testing and researching, I think I’ve uncovered some relevant information about how this works.
Firstly regarding the
Octopus.Action.Package['$referencePackage'].PackageVersion variable, it seems to only be possible to call this by indexing on package ID like you’re attempting when your script step has this package as a reference (refer to doc section below).
I was able to get it to call the PackageVersion from a package deployed via a previous package step by instead specifying the package step instead of package ID like so:
$packageVersion = $OctopusParameters[“Octopus.Action[Package_Step_Name].Package.PackageVersion”]
Octopus.Tentacle.CurrentDeployment.PackageFilePath looks to not be stored as an output variable after it’s set in the package step, meaning it can only be called within the same package step and not a subsequent script step. This variable evaluated as expected when instead calling it in a PostDeploy.ps1 custom script on the package step, for example. But getting it working on the following script step, that might require storing this as an output variable then call that in your script step.
I hope that helps clarify how this works. Let me know what you think and how you go!