Hey,
We want to deploy some .XML files containing encryption keys as part of our Octopus deployments. The files will be different for each environment, and we don’t want to include them in source control as a security measure.
Basically, we want to do exactly what Octopus variable transforms do, only instead of modifying text within an existing file, we want to store entire XML files in Octopus and deploy it alongside the application package based on the target environment.
Is there any way to achieve this without using custom scripts?
Thanks!
Dylan
Hi Dylan,
Thanks for getting in touch! Two approaches spring to mind, The first and simplest is to just paste the entire contents of the XML files into a variable (scoped to each environment). There is no particular limit to how long variables can be. You could then have a PreDeploy.ps1 (https://octopus.com/docs/deploying-applications/custom-scripts) script to dump the variable contents to an XML file on disk.
The second is zip each file into a separate file named keys.ENVIRONMENTNAME.1.0.0.zip
(where ENVIRONMENTNAME is dev, prod etc, whatever your environments are called) and add them to the internal package feed. You can then add a deploy package step called Deploy Keys
that deploys package keys.#{Octopus.Environment.Name}
. Then in your other steps you can get the location the zip was extracted to with the variable Octopus.Action[Deploy Keys].Package.InstallationDirectoryPath
. Note that with this method there is some untidiness with using an expression in the package name like that. You need to manually enter the 1.0.0
as the version when you create the first release (since the create release screen doesn’t have an Environment Name to lookup the right package and find the latest version, and more importantly for crypto keys, package retention policies do not work.
Hope that helps!
Mark