Hi
I am having issues with offline deployment.
I have a step which is a custom PS script. It has a parameter of type “A previous deployment step name”. In the script I am using it :
Octopus.Action[PreviousDeploymentStepName].Output.Package.InstallationDirectoryPath
And the issue is that that variable doesnt exist in variable.json for my current step. So it cant resolve it and deployment step fails cuz it couldnt find files from previous deployment step.
The issue is on this line :
$installDirPathKey = ‘Octopus.Action[{0}].Output.Package.InstallationDirectoryPath’ -f $dacpacPackageStepName
$installDirPath = $OctopusParameters[$installDirPathKey]
Note that it working fine with tentacle deployments, only offline drop fails.
Which Octopus version are you running? If you are not running the latest, I’d recommend you to upgrade your server and try it again. I just tested this on my end running 3.2.3 and it seems to work ok.
If that doesn’t help, please send us a copy of one of your offline packages so we can check it ourselves.
I added output for those variables and it evaluates to
$installDirPathKey = “Octopus.Action[Deploy DACPAC NuGet Package - Local].Output.Package.InstallationDirectoryPath”
$installDirPath = “\content”
$OctopusParameters[$installDirPathKey] = “” <- this is the issue.
Script that you shared is checking for step name, and that’s working correctly it just doesn’t contain variable for “output.Package.InstallDirectoryPath” for that step (apparently non of the output variables are available in offline deployment)
One more thing, When I added variable
Octopus.Action[Deploy DACPAC NuGet Package - Local].Output.Package.InstallationDirectoryPath = "d:\Octopus\Env\1.1.1.1\DACPAC NuGet Package - Local"
to variables (json file) for this step it all worked fine. So the only issue is missing variable or some way of getting it.
Sorry for the delay. I’ve tried to reproduce this on my end using that same Step Template you were using in 2.3.6, but it is still working as expected on my end.
Could you please send me the full unmodified offline package that Octopus is producing? If possible, modify the deployment process so it only has 2 steps: The deploy step and the step that uses the name of the previous step.
You can either set this conversation as Private and attach it on your reply (preferred if the package is small), or you can upload it here: https://file.ac/CIqRKnT8b6w/
Thank you for submitting it. I see its marked as wontfix and we really need this.
Is there any way you might think of that we can use to mitigate this issue? Because in variables its also missing version so I can’t construct the path my self.
It seems I went a bit ahead of myself when creating that github issue. The fact that output variables cannot be used in Offline deployments was a known issue that I totally overlooked. Please accept my apologies for this.
I’ve been thinking about a workaround and I came to a simple enough to implement solution:
The problem:The variable that holds the path where the package was extracted is only available during the NuGet deploy step.
Solution:Use that variable in a script on the Nuget deploy step, and send its value to a txt file that can be read by subsecuent steps.
Setup
Create a variable in your project called textFilePath and assign it a path value like C:\Temp. You’ll see where we’ll be using it in a sec
On your nuget deploy step, enable the Custom Deployment Scripts feature and add the following script as a Deployment script. See attached screenshot
#making sure the path exists
if(!(test-path $textfilepath)){
"$textFilePath does not exist. Creating it..."
new-item $textFilePath -itemtype Directory -verbose
}
#During the deployment step, the variable CustomInstallationDirectory holds the path where the package will be deployed, which is what you want to use from another step
#The below line copies that path to a txt file with the format $textFilePath\[name of the nuget deploy step]
$OctopusParameters['Octopus.Action.Package.CustomInstallationDirectory'] | out-file "$textfilePath\$($OctopusParameters['Octopus.Step.Name']).txt" -verbose -force
This script will create txt file on the path set for $textFilePath with the same name as the deploy step. If you set the path to C:\temp and the deploy step name is Deploy My Package the final path would be C:\Temp\Deploy My Package.txt
Modify the step template to get the content of the txt file created in (1) using the value of the variable textFilePath and name of the step from the dropdown parameter. The below snippet is what I used inside of my test step template
$dacpacPackageStepName = $OctopusParameters['DacpacPackageStepName']
#InstallDirPath will hold the path where the package was deployed.
$installDirPath = get-content "$textFilePath\$dacpacPackageStepName.txt" -verbose
write-host "The name of the deployment step is : $dacpacPackageStepName"
write-host "The path were the package was installed was: $installDirPath"
Let me know if this makes sense and works for you.
FYI - We have a uservoice suggestion to add Output variables to offline deployments. Try to drop by and put some votes on it if you’d like to see this implemented in future versions
Hi,
Since 3.3.0 is almost out, this feature is planned to be included?
In the blog post there is no reference to updates at Calamari level, however in Github there is activity regarding the Calamari.
Unfortunately that feature is still just a suggestion, and its not in our immediate 3.3 plans to implement it. Its still open for vote though cause we might consider get back to it in the future.
Hi,
Thanks for the clarification. Any change to the community sort this out?
There are some ideas around it, and in our case is a showstopper. To
workaround this, the deployment process is clumsy and have more steps than
it should.