build · deployment

Workshop – Playing Sitecore 9 auto-deploy with TeamCity on your machine (Part 1)

This post was 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. setup 03 new Sitecore 9.0 Update 1 instances:
    • 01 sitecore instance whose host name should be viethoang.cm.local
    • 01 sitecore instance whose host name should be viethoang.cd1.local
      • bind another host name tekcent.local
    • 01 sitecore instance whose host name should be viethoang.cd2.local
      • bind another host name demo.local
  2. copy-paste \App_Config\ConnectionStrings.config of cm to overwrite the one of cd1 & cd2 to ensure 03 Sitecore instances using the same databases
  3. install Node.js
  4. install TeamCity
  5. create a new TeamCity project Viet Hoang – Simple Development Framework
    • Administration -> Projects -> Create project (project type: Manually)
  6. create a new TeamCity build configuration CA – CD1 – CD2
    • Administration -> Projects -> Viet Hoang – Simple Development Framework -> Create build configuration
  7. create a new Version Control Settings Vhs_Release
    • Administration -> Projects -> Viet Hoang – Simple Development Framework -> CA – CD1 – CD2
    • left navigation: select Version Control Settings -> Attach VCS root
    • fulfill the fields below:
      • Type of VCS: Git
      • VCS root name: Vhs_Release
      • Fetch URL: https://gitlab.com/viet.hoang/my-simple-framework.git
      • Default branch: refs/heads/%vhs.gitBranch%
      • Authentication method: Anonymous
    • click Test connection to ensure Connection successful!
    • click Save
  8. create Build Steps
    • Administration -> Projects -> Viet Hoang – Simple Development Framework -> 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 #8 to add build step Create VietHoang.Sc.DevSettings.config
    • fulfill the fields below:
      • Runner type: PowerShell
      • Step name: Create VietHoang.Sc.DevSettings.config
      • Script: Source code
      • Script source: copy/paste this one
      • Script execution mode: Execute .ps1 from external file
    • click Save
  11. repeat #8 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 #8 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 #8 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
      • note: if the link above does not work, select latest successful build here https://teamcity.jetbrains.com/viewType.html?buildTypeId=bt434
        • make sure downloaded .zip file is not corrupted
        • adsc9_1
        • put the downloaded plugin .zip file into <TeamCity Data Directory>/plugins folder (normally it’s C:\ProgramData\JetBrains\TeamCity\plugins)
      • restart TeamCity Server via Window Services
      • asd_2.png
  15. repeat #8 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 #8 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
  17. repeat #8 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 2017
      • Test file names: **/bin/%vhs.configuration%/*.Tests.dll
    • click Save
  18. repeat #8 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
  19. repeat #8 to add build step Update gulp-config.js and VietHoang.Sc.DevSettings.config for CD1
    • fulfill the fields below:
      • Runner type: PowerShell
      • Step name: Update gulp-config.js and VietHoang.Sc.DevSettings.config for CD1
      • Script: Source code
      • Script source: copy/paste this one
      • Script execution mode: Execute .ps1 from external file
    • click Save
  20. repeat #8 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
  21. repeat #8 to add build step Update gulp-config.js and VietHoang.Sc.DevSettings.config for CD2
    • fulfill the fields below:
      • Runner type: PowerShell
      • Step name: Update gulp-config.js and VietHoang.Sc.DevSettings.config for CD2
      • Script: Source code
      • Script source: copy/paste this one
      • Script execution mode: Execute .ps1 from external file
    • click Save
  22. repeat #8 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
  23. repeat #8 to add build step Sites Warm-up
    • fulfill the fields below:
      • Runner type: PowerShell
      • Step name: Sites Warm-up
      • Script: Source code
      • Script source: copy/paste this one
      • Script execution mode: Execute .ps1 from external file
    • click Save
  24. repeat #8 to add build step Sync Unicorn
    • fulfill the fields below:
      • Runner type: Gulp
      • Step name: Sync Unicorn
      • Gulp File: gulpFileForUnicorn.js
    • click Save
  25. finally we’ve just done for all the build steps
    • adsc9_11.png

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.

2 thoughts on “Workshop – Playing Sitecore 9 auto-deploy with TeamCity on 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 )

Google+ photo

You are commenting using your Google+ 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 )

w

Connecting to %s