Back

Ruling the continuous integration seas with Sitecore.Ship - Part 1

Why the hell are you deploying Sitecore packages manually?

Deploying Sitecore items

All software development projects that involve Sitecore are faced with the same problem: how to get the Sitecore items (templates, layouts or content) from development to the other environments in a consistent way.

Tedious and error prone: manual deployment o_O

During my first couple of Sitecore projects the packaging and deployment of Sitecore items was a manual struggle process. Item packages were created using the Package Designer and the resulting packages were installed using the Installation Wizard once the website was deployed.

There are several downsides to this manual approach:

  • Developers can easily forget to include required items in the package (especially if they pick items the static way instead of the dynamic way).
  • Correct package installation is never guaranteed to happen in the same way across all environments (or even at all!) because a developer needs to:
    1. Wait until the regular deployment of files is finished (if this takes long the next steps might be forgotten),
    2. Upload the right packages,
    3. Install the packages in the right order (and select the correct installation options).

This manual process is very tedious and error prone, even when it's done by just one person. Fortunately several tools emerged over the years which make packaging and deploying Sitecore items a breeze.

Developer friendly and consistent: Sitecore Ship

One of the tools that made my life a Sitecore developer easier is called Sitecore.Ship. Sitecore.Ship is a small Sitecore module developed by Kevin Obee and it allows the installation of Sitecore packages (both .zip and .update) using HTTP requests. The packages could be either generated by TDS, Courier or... still by hand (but you wouldn't do that anymore right? ;).

I like Sitecore.Ship for two reasons:

  • It's a compact module which only does a limited number of things and it does these right. I usually prefer smaller tools over larger ones because smaller tools are easier to understand and work with. And if there are less moving parts there is also less risk that something breaks.
  • It can be easily integrated in a continuous integration setup using a scripting language such as Powershell.

Using Sitecore.Ship

Sitecore.Ship can be added to your Visual Studio project using NuGet. There are currently two NuGet packages to choose from:

  • Sitecore.Ship - This version uses Nancy, a lightweight .Net framework for building HTTP based services. Note that your web project will add a dependency to Nancy.Hosting.AspNet.
  • Sitecore.Ship.AspNet - This version uses a plain ASP.Net HttpHandler implementation and therefore requires no additional dependencies.

Sofar I've mainly used the Sitecore.Ship.AspNet version because I didn't want to introduce additional dependencies to my projects. I've used the 0.3.5 version for Sitecore 7.1 and the 0.4.0 (pre-release) version for Sitecore 8.0 (from Initial up to Update-5).

What's in the NuGet?

Let's have a look what's in the NuGet packages of the 0.4.0 pre-release version (since we're all using Sitecore 8 anyway right? ;).

This is the contents of the Sitecore.Ship package:

Sitecore.Ship NuGet package

This is the contents of the Sitecore.Ship.AspNet package:

Sitecore.Ship.AspNet NuGet package

The assemblies involved are:

  • Sitecore.Ship.Core.dll - Contains the interfaces, domain objects and services for recording the package installation and parsing the packages.
  • Sitecore.Ship.Infrastructure.dll - Reads the configuration, performs logging, reads/writes the package deployment history and performs the actual installation of items using the Sitecore API. This assembly has dependencies to Sitecore.Kernel, Sitecore.Logging, Sitecore.Update and Sitecore.Zip.
  • Sitecore.Ship.dll - Contains Install and Publish modules (based on NancyModule) which define the HTTP requests that can be executed.
  • Sitecore.Ship.AspNet.dll - Contains the SitecoreShipHttpHandler and the various CommandHandlers for uploading and installing packages and publishing items.

Once the website files are deployed you can issue a POST request to <website>/services/package/install/fileupload in order to upload and install a package. Or do a smart publish by doing a POST to <website>/services/publish/smart. As usual though the devil in the details and while the wiki page gives some basic guidance how to start using Sitecore.Ship it is not a complete end-to-end guide how to integrate it in your solution.

In the next blog post I will explain in detail how I'm using Sitecore.Ship with Powershell and cURL in continuous integration setups with tools like Visual Studio Release Management or Octopus Deploy.