Sitecore Continuous Integration, part 1

Usually during standard process of development you would have several environments like DEV, QA, UAT/STAGING and so on. The more environments you have - the more cases and differences in deployment you will need to implement. In this post I would try to describe how you could simplify your life implementing CI for Sitecore based projects.

Almost immediately you would face a question of content synchronizations. There are a lot of options that you could use:

  • Content Package - the most obvious variant one could come up with however you cannot automate it out of the box. Automation of content packages deployment is quite complex task  as you need invent versioning for them, need to store in them in VCS
  • Unicorn project - solution based on content serialization. You will need to integrate some event handlers on content changes in order to keep sitecore serialization folder up to date. It will allow you to update content via http call from CI as well.
  • Hedgehog TDS - this is an extension to Visual Studio that does a lot more that just serialization. You could merge content, sync from VS generate code based on templates and so on. With CI it could be integrates quite easily as you just need to build project with specific setting.
  • Database project - more or less standard variant when it came to DB sync, but with Sitecore it would not work as good as expected. You will not have any control of sync of sitecore items and after some period of time it will be extremely long operation especially if you have some media items in DB. 
From my practice TDS - is the most useful tools, but it is not free so you need to decide for yourself.

Moreover, when it comes to users and role synchronization - none of this tools will, except DB project (but I would not recommend it due to reasons above). To solve this issue I've come up with several pipelines that could be started on Sitecore init and check roles needed or even create them. The most suitable place for this operation is initialize pipeline.
Processor implementation for this pipeline is quite simple - we just chech and create roles if the do not exist (see gist below). Users creation is little bit more complex and require different configurations for each environment. To do this you will need transforms for include configurations. I will describe tools and approach in following articles.

Sitecore: extending field datasource queries with tokens

It is quite common situation when you need to create data source query for a field in a template that is quite complex: e.g you would like to use current item property as a part of a query or you have dependency on some other item in a content tree.

In case of list fields you could use GetLookupSourceItems pipelines to modify query according to your requirements.

As usual you will need to register this pipeline in sitecore patch file and put it in <web root>/app_config/include

Finally, to use it need to use defined token in a field query, when you defining your template.

Simple, but give you a lot of flexibility.

Sitecore: multisite solution organization

Reading Sitecore manuals or digging in the Internet you probably see a following statement: "Information Architecture is very important for Sitecore solution". So I would like to share some thoughts and approached.
Nowadays I'm mainly working with MVC and this post is also about it, but a lot of stuff could be applicable to WebForms as well.

Sitecore: using MVC areas

Sitecore out of the box will not provide MVC ares support but you will really need this functionality for good solution organization. However, Sitecore has good pipelines system and you could plug you code that will resolve areas.

Sitecore: logging via RabbitMQ

In previous post I've described why I've started to look into RabbitMQ integration. Here you could find its implementation.

Sitecore + RabbitMQ implementation

In order to send log data from Sitecore we need to extend its Logger. Sitecore uses logging system based on log4net (it is their own implementation and based not on the latest log4net sources) so we could try to use existing open source module from NuGet at least as a reference.

I took the module, replace log4net reference to Sitecore.Logging dll and made all needed changes. All this code you could find on GitHub in pre-beta version.
GitHub: Sitecore.Logger.RabbitMQ.GelfAppender

Sitecore: Logging with EKL (ElasticSearch+Logstash+Kibana)

Why not to use standard files?

Usually when you are working with Sitecore you will have standard file based logs. For development this is more that enough but when it comes to other environments it could be very nice to have all logs sentralized. Moreover need to be sure that logs are not lost in cases when something went wrong and it is easy to find information in it.
So my goal is to create solution base on EKL (ElasticSearch+Logstash+Kibana) which will get log data from Sitecore and provide possibilities to search and work with them. ()


Kibana Query interface