We have teams in the process of moving lots of apps to Octopus and making a few mistakes as part of this process. Is there a way to hook into the substitution engine and somehow “preview” a configuration transformation with variable substitution? It would be extremely helpful to say preview what the end result web.config will look like for a Production deployment before actually deploying to production (because someone will screw it up).
Thanks for reaching out. This isn’t possible at the moment but there’s a uservoice sugestion for this: https://octopusdeploy.uservoice.com/forums/170787-general/suggestions/7333670-preview-transforms-for-an-environment . Please drop by if you’d like to see it implemented and add some votes. A few of us in the team have already expressed that we like it, but we need the community to root for it before we put it in our (already busy) queue.
From looking at the Calamari code on GitHub, it seems like we should be able to make a call to Calamari.Integration.Substitutions.FileSubstitutor.PerformSubstitution() with the transformed file. But where does the VariableDictionary ultimately come from? I see that it may originate from DeployPackageCommand(), but I don’t see how it’s actually instantiated and initialized with the values from the database. If there’s any info you can give me there, perhaps we can hack something in as a stop gap for my team.
I’m taking this over as Dalmiro is headed of on some leave. While Calamari does these calls OD server itself orchestrates the transformation and applies the variables.
That is where they come from.
I had an idea - when we provide the files for a package drop, we also provide the variables in a JSON format that can be used by variable substitution, you could use that to come up with something. Or you could create your own variables list. Have a go at adding a drop target to that environment, and look at the scripts. It might get you started.
Very interesting. If all of the “final” variable values are provided in the
JSON, then it may be something I can work with. Let me look into that.
I created a little powershell script that will take in a variable JSON file from a drop target, a web.config, and a web.foo.config transform file and spit out a transformed file with the final substitutions. Here’s a link to the GitHub Gist: https://gist.github.com/nshenoy/79ac16c84edcc65485dff263d1e2781f . This is just an initial stab at it, but seems to work ok for what we need. Hopefully someone may find this helpful.
That is really great! Thanks for sharing! I’ve shown the team
I blogged a walkthrough for how to use this: https://repne.wordpress.com/2016/06/10/previewing-octopus-web-config-transforms-via-offline-package-drops/ . Feedback welcome.
The blog post is great, no other feedback