14 January 2015

Few steps torward automated deployment

A know a few people will be in favour of "You need to setup the full automated deployment right away"... Well, I don't think this is that easy, you have to look at your timeframe to deliver the project, the client budget, infrastructure and all the tools you have. So I was looking a bit into a starting point. Tis might not be the best method in the world, but I needed to get something started then get it grow and one day we will get a fully CI...

1- Get TDS to generate my .Update packages:

In a few projects now, I have been using TDS to generate my update packages to deploy to Internal QA, UAT and production. First we started to deploy those manually which is the first step: we already saving a bit of time not having to generate those packages manually.

2- Build server

Then we have been using a build server - awesome: now the packages will be generated by the build server... Better than my dev machine :)

3- Copying the packages to the relevant Instance

Well, I came short in this area but lucky there are few guys here who could help out. So we have been using Jenkins to take the output packages from TDS and place it into a folder on the Internal QA server. In this sitecore instance, we have created a handler (ashx) that will:
  • Look for the packages in this location
  • Serialise the content tree to make sure we have a backup before installing the packages
  • Backup the files
  • Install the packages.
  • Publish the items
  • Rebuild the indexes
I just wanted to throw some code we used for the different actions so if you are interested in, you can have a starting point

Serialising the tree:
well that is the easy bit - for this code sample I will take the entire tree:

using Sitecore.Data;
using Sitecore.Data.Items;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace MyProject.sitecore_modules.MyProject
    public partial class Backup_Site : System.Web.UI.Page
        string SitecoreRootItem = "{11111111-1111-1111-1111-111111111111}";

        protected void Page_Load(object sender, EventArgs e)

        public void BackupItemTree(string id)
            Database db = Sitecore.Configuration.Factory.GetDatabase("master");
            Item itm = db.GetItem(id);


As I said, it is not the best, but still it is a first step to save time during deployment and a step forward in the Continuous Integration.

No comments:

Post a Comment