build · deployment

Workshop – Automating Sitecore deployments with TeamCity at your machine (Part 1)

This post is used for my workshop at the company. However, it might be an initiative of your own approach for the automating Sitecore deployments with TeamCity. (Note: the summary is here)

Setup Prerequisites

How to set it up

  1. use SIM if possible to setup 03 new Sitecore 8.2 Update 2 instances:
    • 01 CA whose site name should be viethoang.ca.local
    • 01 CD whose site name should be viethoang.cd1.local
    • 01 CD whose site name should be viethoang.cd2.local
  2. copy-paste \App_Config\ConnectionStrings.config of CA to overwrite the one of CD1 & CD2 to make sure 03 Sitecore instances using the same databases
  3. install Node.js
  4. install TeamCity then log into TeamCity
  5. create a new TeamCity project Vh Local
    • Administration -> Projects -> Create project
  6. create a new TeamCity build configuration CA – CD1 – CD2
    • Administration -> Projects -> Vh Local -> Create build configuration
  7. create a new Version Control Settings Vh_Release
    • Administration -> Projects -> Vh Local -> CA – CD1 – CD2
    • left navigation: select Version Control Settings -> Attach VCS root
    • fulfill the fields below:
      • Type of VCS: Git
      • VCS root name: Vh_Release
      • Fetch URL: https://gitlab.com/viet.hoang/my-simple-framework.git
      • Default branch: refs/heads/master
      • Authentication method: Anonymous
    • click Test connection to make sure Connection successful!
    • click Save
  8. create Build Steps
    • Administration -> Projects -> Vh Local -> CA – CD1 – CD2
    • left navigation: select Build Steps -> Add build step
  9.  add build step Create gulp-config.js file local
    •  fulfill the fields below:
      • Runner type: PowerShell
      • Step name: Create gulp-config.js file local
      • Script: Source code
      • Script source: copy/paste this one
      • Script execution mode: Execute .ps1 from external file
    • click Save
  10. repeat #6 to add build step Create z.VietHoang.SerializationSettings.config
    • fulfill the fields below:
      • Runner type: PowerShell
      • Step name: Create z.VietHoang.SerializationSettings.config
      • Script: Source code
      • Script source: copy/paste this one
      • Script execution mode: Execute .ps1 from external file
    • click Save
  11. repeat #6 to add build step Create publishsettings.targets
    • fulfill the fields below:
      • Runner type: PowerShell
      • Step name: Create publishsettings.targets
      • Script: Source code
      • Script source: copy/paste this one
      • Script execution mode: Execute .ps1 from external file
    • click Save
  12. repeat #6 to add build step Deploy All Serialization Folders To Sitecore Server
    • fulfill the fields below:
      • Runner type: PowerShell
      • Step name: Deploy All Serialization Folders To Sitecore Server
      • Script: Source code
      • Script source: copy/paste this one
      • Script execution mode: Execute .ps1 from external file
    • click Save
  13. repeat #6 to add build step Create GlobalAssemblyInfo.cs file
    • fulfill the fields below:
      • Runner type: PowerShell
      • Step name: Create GlobalAssemblyInfo.cs file
      • Script: Source code
      • Script source: copy/paste this one
      • Script execution mode: Execute .ps1 from external file
    • click Save
  14. install Gulp build runner to run gulp scripts
    • Upload Gulp build runner to TeamCity
      • Administration -> Plugins List -> Upload plugin zip
      • asd_1
      • restart TeamCity Server via Window Services
      • asd_2.png
  15. repeat #6 to add build step Restore Node modules
    • fulfill the fields below:
      • Runner type: Node.js NPM
      • Step name: Restore Node modules
      • npm commands: install
    • click Save
  16. repeat #6 to add build step Restore Nuget Packages
    • fulfill the fields below:
      • Runner type: Nuget Installer
      • Step name: Restore Nuget Packages
      • Nuget.exe: 3.5.0 (or later)
        • If there are no any Nuget.exe, please install it:
          • Administration -> Tools -> Install Tool…
          • asd_10
      • Path To Solution File: %vh.solutionFile%
      • Restore Mode: Restore (requires NuGet 2.7+)
    • click Save
  17. repeat #6 to add build step Build Test Projects
    • fulfill the fields below:
      • Runner type: Gulp
      • Step name: Build Test Projects
      • Gulp File: gulpfileForTest.js
    • click Save
  18. repeat #6 to add build step Get Test Results
    • fulfill the fields below:
      • Runner type: Visual Studio Tests
      • Step name: Get Test Results
      • Test engine type: MSTest
      • Test engine version: MSTest 2015
      • Test file names: **/bin/%vh.buildConfiguration%/*.Tests.dll
    • click Save
  19. repeat #6 to add build step Build and publish the solution to CA
    • fulfill the fields below:
      • Runner type: Gulp
      • Step name: Build and publish the solution to CA
      • Gulp File: gulpfile.js
    • click Save
  20. repeat #6 to add build step Sync Unicorn
    • fulfill the fields below:
      • Runner type: Gulp
      • Step name: Sync Unicorn
      • Gulp File: gulpFileForUnicorn.js
    • click Save
  21. repeat #6 to add build step Update gulp-config.js for CD1
    • fulfill the fields below:
      • Runner type: PowerShell
      • Step name: Update gulp-config.js for CD1
      • Script: Source code
      • Script source: copy/paste this one
      • Script execution mode: Execute .ps1 from external file
    • click Save
  22. repeat #6 to add build step Build and publish the solution to CD1
    • fulfill the fields below:
      • Runner type: Gulp
      • Step name: Build and publish the solution to CD1
      • Gulp File: gulpfile.js
    • click Save
  23. repeat #6 to add build step Update gulp-config.js for CD2
    • fulfill the fields below:
      • Runner type: PowerShell
      • Step name: Update gulp-config.js for CD2
      • Script: Source code
      • Script source: copy/paste this one
      • Script execution mode: Execute .ps1 from external file
    • click Save
  24. repeat #6 to add build step Build and publish the solution to CD2
    • fulfill the fields below:
      • Runner type: Gulp
      • Step name: Build and publish the solution to CD2
      • Gulp File: gulpfile.js
    • click Save
  25. repeat #6 to add build step Update LastSuccessfulBuildDateTime To File
    • fulfill the fields below:
      • Runner type: PowerShell
      • Step name: Update LastSuccessfulBuildDateTime To File
      • Script: Source code
      • Script source: copy/paste this one
      • Script execution mode: Execute .ps1 from external file
    • click Save
  26. repeat #6 to add build step Warm up CD Sites
    • fulfill the fields below:
      • Runner type: PowerShell
      • Step name: Warm up CD Sites
      • Script: Source code
      • Script source: copy/paste this one
      • Script execution mode: Execute .ps1 from external file
    • click Save
  27. finally we’ve just done for all the build steps
    • asd_7

What’s next?

We will fulfill the value of all the configuration parameters so that the automating deployment will be able to run successfully in Part 2.

Advertisements

2 thoughts on “Workshop – Automating Sitecore deployments with TeamCity at your machine (Part 1)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s