LibrarySites.Banner

Sitecore Update and Zip Package Installer Web Service

Overview

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.

Implementation

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.

https://gist.github.com/mskutta/c9fe547ac03895f3b087

Usage

All we need to do is drop the PackageInstaller.asmx in Sitecore. From there, we can call it from a PowerShell script.

 
CAUTION: The PackageInstaller.asmx does not have security restrictions. Anyone that knows about the web service can install both .update and .zip packages as long as the packages are on the file system. For security reasons, I deploy the PackageInstaller.asmx at the beginning of the Octopus Deploy process and remove it once the process is complete.
 

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.

https://gist.github.com/mskutta/be7b7bcabf4a54ddea1a