Confused about how variables are passed between steps

I’m very confused about Output Variables and passing info between steps overall. Probably I’m missing something. Let’s say I have a two stop process - first step is obtaining a package and second step should upload one file from the package to Azure Blob. I need to figure out a way in a second step to determine where the package was unzipped to, but I can’t figure out for the life of me how system variables works in Octopus. I came up with a way to troubleshoot this:

First step:
Write-Output "ExtractedPath: " $OctopusParameters[“Octopus.Action.Package[grmapi].ExtractedPath”]
Write-Output "InstallationDirectoryPath: " $OctopusParameters[“Octopus.Action.Package.InstallationDirectoryPath”]
Write-Output "PackageFilePath: " $OctopusParameters[“Octopus.Action.Package[grmapi].PackageFilePath”]

Set-OctopusVariable -name “ExtractedPath” -value $OctopusParameters[“Octopus.Action.Package[grmapi].ExtractedPath”]
Set-OctopusVariable -name “InstallationDirectoryPath” -value $OctopusParameters[“Octopus.Action.Package.InstallationDirectoryPath”]
Set-OctopusVariable -name “PackagePath” -value $OctopusParameters[“Octopus.Action.Package[grmapi].PackageFilePath”]


Second step:

Write-Output "ExtractedPath: " $ExtractedPath
Write-Output "InstallationDirectoryPath: " $InstallationDirectoryPath
Write-Output "PackagePath: " $PackagePath

try {
ls $ExtractedPath
ls $InstallationDirectoryPath
ls $PackagePath


What am I doing wrong? Is there even a way to do what I want - obtain a package in one step and modify a file from it in a second step?

I should probably try to explain what I’m trying to do. I have a package with two things inside - Helm charts for deployment to Kubernetes and a desktop application which should be uploaded to Azure Blob. Both charts and app are built for specific customer, so the application can work only with Docker images that are baked in into this specific Helm charts (that’s why I’m not using separate packages). I want to deploy charts in the first step, then have an approval step and then in the third step upload the app to Azure. If I’m referencing the same package in both steps, my release has references to the same package twice, which doesn’t seem right to me.

So I’m trying to find a way to use the same package in both steps - charts deployment step and application upload step.
All customer specific variables are stored in Octopus, so I can’t bake them in during a build process in my CI.

Hi @ilyat,

Thanks for getting in touch, and good question! To reference output variables created by a previous step, you would need to reference the step name that created the variable. In this case, I believe a built-in output system variable is created which would make referencing the contents of the extracted package much easier, namely Octopus.Action[StepName].Output.Package.InstallationDirectoryPath (where StepName is step that deploys your package).

My guess is you might just need to grab that automatically created variable in step two, with something like:

$ExtractedPath = "Octopus.Action[StepName].Output.Package.InstallationDirectoryPath"
Write-Output "ExtractedPath: " $ExtractedPath

We have some additional documentation on output variables and system variables which might be of use, and I hope this helps make some progress. Let me know how you go, or if I can try to help with anything going forward!

Best regards,