Apply Kentico Hotfixes when running Kentico Continuous Integration

By Ilesh Mistry
May 26th 2017

10 minute read

I am sure we have all been involved in applying Kentico hotfixes or Kentico upgrades. Even if you have not been involved, you are hopefully aware of the processes involved and where to look for the best help and guidance on it, via the Kentico documentation website.

Applying hotfix overview

This blog post will focus on applying hotfixes rather than upgrading Kentico. Here are a few ways to apply hotfixes...

1) Download the hotfix and run the utility using the installer. This is a great area to see what the latest hotfixes are and you can also check what fixes were added, using the small search utility.

2) Download and install the Kentico hotfix using the Kentico Installation Manager (KIM). KIM is a central management application for handling hotfixes and upgrades. It's very simple to use and it is my preferred tool when it comes to applying a hotfix and/or upgrading a Kentico site.

For more information on this, follow the Kentico documentation on it.

Dev tip –

Before applying hotfixes, always check the hotfix notes to make sure you follow any additional tasks you will need to undertake.

So applying a Kentico hotfix is a pretty simple process, but you need to make sure you take a backup of your files and database before you proceed, just in case you need a roll back state. I would also recommend following Kentico's tips on what else you would need to do.

Dev tip –

To help with Kentico upgrades and hotfixes, you also need to follow the best practices, when developing in general and make sure objects that shouldn't be amended are not or you have some way of tracking them and recovering them if or when they get overwritten. If you follow this, then it will help when upgrading a site or applying a hotfix.

Okay, I am assuming you know how to apply a Kentico hotfix right?

Generally, applying a Kentico hotfix is fine, but we have started to work with a different set up using Kentico CI.

Kentico CI is awesome and allows you to collaborate while working in a local database environment. Kentico CI serialises various Kentico objects into XML files which can then be used to pass between your teams via your version control system e.g. GIT. This saves the need for the traditional shared database approach of manually adding object changes via exporting and importing or using the content staging module or Compare for Kentico (which is an awesome tool!).

Applying hotfix with Kentico CI running

For you to apply a Kentico hotfix while running Kentico CI, you would need to follow the below steps.

It’s worth noting that these may differ for you, depending on your development setup and teams.

  1. Pull everything from the e.g. development branch
  2. Run the Kentico CI restore tool to bring in any changes from the branch into Kentico e.g. ContinuousIntegration.exe -r
  3. Create a new feature branch for the hotfix
  4. Read the instructions for the hotfix you wish to apply and the Kentico documentation additional steps required for hotfixes
  5. Using KIM, download and apply the latest or required Kentico hotfix
  6. Once you have applied the hotfix using the recommended guide, have a look at the changes it has applied in the modified list in your source control tool to give you an indication of what has changed. e.g. SourceTree.
  7. Look through the list and decide whether to keep all the changes or not. In this particular case, the Visual Studio solution file had been updated and removed - something we actually needed, so because of this we discard that change from the hotfix and keep everything else.
  8. Next, look in the Kentico admin area to see that the version number has changed
  9. Check that everything is fine and test the website to check for any breaking changes. Once you're happy, then you need to commit all your changes
  10. Pull from development branch to make sure you are all up to date with any other changes and resolve any conflicts.
  11. Once you're happy, push the changes via a Pull Request, if you're not using pull requests, push as you would normally and go to step 13.
  12. Once the pull request gets accepted, it will need to be merged into the development branch.
  13. That's it! Or is it?

You have done your bit and have the latest Kentico hotfix, happy days right?

That is good news for you, however your colleagues need to pull these changes down to get the hotfix files. In doing this, they will only have the files that were updated from the hotfix and not all the database changes. Therefore, they will need to apply the hotfix via the following steps...

1) Pull the changes from the development branch.

2) Run the Kentico CI restore tool to bring any changes from the branch into Kentico e.g. ContinuousIntegration.exe -r

3) Now if they look in Kentico, they will see their hotfix version has changed

This is misleading, there is a text file located in the following file location \CMS\App_Data\Install\hotfix.txt, which has been incremented in the file system.

4) For you to check this further you will need to perform a further check in the database, by making sure that the 'keyname' fields in the CMS_SettingsKey table are correct. The fields 'CMSDataVersion' and 'CMSDBVersion', should refer to the major version of Kentico e.g. 10 and the 'CMSHotfixVersion' tells you the actual hotfix version you have applied e.g. 12.

You can use this SQL script if you want to see this...

FROM [tch_local_db_01].[dbo].[CMS_SettingsKey]
WHERE  [KeyName] like '%DataVersion%'
    OR [KeyName] like '%DBVersion%'
    OR [KeyName] like '%HotfixVersion%'
ORDER BY [KeyValue]

5) What you will notice is that the full database changes will not come through with Kentico CI, so you would need to apply the SQL script manually. So if you or a colleague have downloaded the hotfix before, then if you look in the folder where it is installed e.g. C:\Program Files (x86)\Kentico\10.0\Hotfix100_12, you will see SQL files in the 'SQL' folder.

This is dependent on your setup, so if you have your database spilt between online marketing and CMS (use the separated file Hotfix_separated.sql) or if it is just a standard combined route of no split (use the default file Htofix_default.sql), you will need to run one of the SQL queries on your colleague's machine in their SQL Management Studio or alternative.

6) Once this has run and completed without errors, you can rerun the SQL script from step 4 above and make sure the actual database elements have been updated.

7) This will now have successfully applied the remaining items for the hotfix and your colleague can carry on with their work.

That's it, you will need to repeat this process for each member of the team. Also you will need to consider how this could be achieved on different environments when you're in development phases, as you may have to make sure that they too are up to date with the latest hotfixes.

Time to think about this more?

So you must be wondering, can we improve this process?
Can we run these scripts automatically?
If so how can we achieve this?

Find out more in the next part of this blog post series - Automate database changes from Kentico Hotfixes when running Kentico Continuous Integration using DbUp and GruntJS, which will be coming soon.