I am in the process of automating Sitecore deployments using Octopus Deploy. As part of this process, I need to install .update packages that are generated by TDS and also .zip packages generated by developers. Out of the box, Sitecore provides a way to manually upload these packages through the backend GUI. They also provide an API to upload the packages.
Octopus Deploy has the ability to run PowerShell scripts as part of its deployment process. I need a way to install the packages through a PowerShell script. One way to achieve this is to create a custom web service that uses the Sitecore API to install the packages. The PowerShell script can then call the web service. Using a blocking web service, Octopus Deploy will wait until the installation of the packages completes.
Hedgehog Development, the developers of TDS, created an UpdatePackageInstaller github repository. This repository contains example code of how to install .update packages via the API. I used the example provided in TdsPackageInstaller.cs as a starting point.
I also found the Exporting and Importing packages from Sitecore through Code using Sitecore API by Akshay Sura very helpful. I used this as a starting point to import .zip packages.
Putting both examples together, I created a web service that supports installing .update and .zip packages.
All we need to do is drop the PackageInstaller.asmx in Sitecore. From there, we can call it from a PowerShell script.
Here is an example of how you can use PowerShell to call the web service. This example was taken from the Octopus Deploy PostDeploy script. The script automatically installs all .update and .zip packages located at the standard locations in the Sitecore file structure.
Awesome. Thank you much. We are deploying using an Azure Cloud Service and this is just what I was looking for at the end of the Startup task. We can copy the asmx from cloud storage, run the package install and then delete the asmx.
Hi, We use octopus deploy to deploy various sitecore packages, using the code above. They all work fine, apart from the deployment of a package that contains roles and users. The roles and users are not successfully imported. Is this by design? Regards, Richard Buckingham
Hi, Richard It is right, and we are using similar code. Actually, to allow security installation you have to add after "installer.InstallPackage(Sitecore.MainUtil.MapPath(path), context); " on more code string: "installer.InstallSecurity(Sitecore.MainUtil.MapPath(path));" - and your security will be imported.
i need for helpfull zip package
I don't see the example. Is there an issue with the blog post?
For a version of this post with inline examples, please see: mskutta.github.io/.../