A unique opportunity has arisen for me. I have been tasked with building a fully automated build and deployment solution for Sitecore. So I have documented everything that I have done and will be presenting everything that I have done in a series of posts.
Part 1 – this post
Part 2 – Setting up OctopusDeploy
Part 3 – Setting up SQL Server for Sitecore
Part 4 – IIS
Part 5 – Octopus Environment and Deployment Configuration
Part 6 – TeamCity Project
Part 7 – OctopusDeploy Project
Part 8 – Sitecore Item Synchronization using Unicorn
Part 9 – Displaying Build number on Sitecore Home Page & Tagging Git
Part 10 – config transformations using Octopus Deploy
Part 11 – Deploying to a Sitecore Multi-Instance Configuration
For this I have been using the following tools:
I wont be listing everything in this post I will be breaking it down. First I will be detailing my first steps in setting up TeamCity
So a few assumptions. I have not listed every tool / application that I am using. I am using git Stash from Atlassian, but any git or other distributed source control system should work. I have not used Microsoft’s TFS so I have no idea if what I have done will work with a centralized source control repository.
All the servers are running Windows Server 2012 R2.All the servers are stand alone, and are not part of a domain. All servers have C and D drives.
Everything that is documented here and on subsequent posts are based on freshly installed Windows Servers.
At least one Local Administrator account should be created so that you are not using the default Administrator account that is created during installation. However by default, the Local Security Policy for Windows Servers is to have passwords expiring every 42 days. As want to create accounts that do not have an expiring password, this will need to be disabled. The accepted default is to disable password expiration from the Local Security Policy
From Start Menu Run “Local Security Policy”
Navigate to Account Policies | Password Policy. Double click “Maximum password age” and set the value to 0.
Before starting download the following software. It will be used during this setup
- TeamCity I downloaded v9
- SQL Server 2012 Express
- SQL Server JDBC Driver Do not install preview. At time of writing latest driver was sqljdbc 4.2. File sqljdbc_4.2.6420.100_enu.exe
- MS Build Tools
- Octopus Teamcity Plugin
Create the following drives as they will be needed later
In preparation for Teamcity, several environment settings need to be added to the path. From Control Panel select System.
Select Advanced System Settings, and select the Advanced tab.
Finally click on Environment Variables
Set variable name to TEAMCITY_SERVER_OPTS
Set Variable value to -Djava.library.path=D:\TeamCity\Data\lib\
As I wanted to run TeamCity under a seperate administrator account the first step is to create a new User Account. From Control Panel select User Accounts | Manage another Account
Click “Add a user account”
You can pick whatever name you want, but I decided on TeamCity-Admin.
For the password, I used https://www.passwordgenerator.com to generate a strong password.
Once the account has been created, click on “Change the account type”
And select Administrator
Finally click Change Account Type
For this, I am going to be using SQL Server Express. What version you eventually end up using should have no impact on TeamCity
From the software downloaded, run SQLEXPRWT_x64_ENU.exe
Select New SQL Server stand-alone installation or add features to an existing installation
Accept the license terms and click Next
Accept default to include SQL Server product updates
Let the setup files be installed
For Feature Selection leave as default
Leave instance Configuration with default options.
Change the SQL Server Browser to Automatic Startup Type
Teamcity requires a case sensitive collation. Switch to the Collation tab
Ensure Case Sensitive is clicked
From the Server Configuration tab, click Next
I prefer mixed mode instead of only Windows authentication mode.
Generate a secure random password to be assigned to the SA account
Click the Add button as want to add the TeamCity admin account created earlier as an administrator account
Switch to the Data Directories tab.
All the data directories will be created on the D Drive. I prefer to use a folder called SQLData for the data files and SQLBackup for all backup files.
Set Data root dictionary, User database directory, User database log directory, Temp DB directory, and Temp DB Log directory to D:\SQLData
Set Backup Directory to D:\SQLBackup
No changes are necessary on the User Instances tab
No changes are necessary on the FILESTREAM tab
For Error reporting, leave unchecked and click Next
Now wait for SQL Server to be installed
Click Close to complete the SQL Server installation
Now need to create the Teamcity Database, and default SQL user for Teamcity
Run SQL Management Studio
Log in using either Windows Authentication,
or using the SA account
Run the following SQL script to create the database that Teamcity will use. Again I have defaulted the locations to the default of D:\SQLData.
CREATE DATABASE [Teamcity] CONTAINMENT = NONE ON PRIMARY ( NAME = N'Teamcity', FILENAME = N'D:\SQLData\Teamcity.mdf' , SIZE = 256000KB , FILEGROWTH = 51200KB ) LOG ON ( NAME = N'Teamcity_log', FILENAME = N'D:\SQLData\Teamcity.ldf' , SIZE = 102400KB , FILEGROWTH = 10240KB ) COLLATE Latin1_General_CS_AS GO
Run this script to create user
USE [master] GO CREATE LOGIN [teamcity] WITH PASSWORD=N'teamcity', DEFAULT_DATABASE=[Teamcity], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF GO ALTER SERVER ROLE [sysadmin] ADD MEMBER [teamcity] GO
Final SQL Server step is to configure SQL.
Run SQL Server Configuration Manager
Select SQL Server Network Configuration | Protocols from SQLExpress
Update TCP/IP to “Enabled”
Select SQL Server Services.
Ensure that the Start mode for SQL Server browser is Automatic. Start the service if it is not already running.
SQL Server is now in a state we can now start to install Teamcity
Pre Setup – SQL JDBC
Copy sqljdbc42.jar that was previously downloaded and extracted and copy to D:\TeamCity\Data\lib\jdbc
Copy sqljdbc_auth.dll that was previously downloaded and extracted and copy to C:\Windows\System32
Pre Setup – MS Build Tools
Run BuildTools_Full.exe that was downloaded previously
Once the installation has completed, click Close button
I found an issue where not all the relevant build files are installed. Especially projects build using Visual Studio 2013 and Visual Studio 2015. So from a machine that has Visual Studio installed, copy across the following folfers and copy onto the same folder locations on the TeamCity server
- C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Web
- C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\WebApplications
- C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web
- C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\WebApplications
- C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\SSDT
Click on Next
After reading the Licence Agreement, click I Agree button to accept the Licence Agreement.
Change the destination folder to D:\Teamcity, and click Next button
Select all the defaults and click Next button
Use the default port of 80 and click Next button
Accept the default Build Agent properties, and click Next button
Click ok to confirm that the properties where saved.
Select Run TeamCity under a User Account, and click Next button
Insert the credentials for the TeamCityAdmin account created previously, and click the Next button
For the Service Account, select Run under a user account. Click Next button to continue.
Enter the TeamCityAdmin account created previously,and click the next button to continue.
Ensure that tick the boxes to start both services, and click the next button
Allow TeamCity to install and click the Finish button to complete the installation
Teamcity First Run
Now that TeamCity has been installed, the first time you access the site, you will need to configure TeamCity for use. For all of the setup, I performed these steps while I had RDP’ed on the server. Therefore the address for everything is http://localhost.
As the images taken where from a live customer project, I have blanked out the customer and the project’s names in all images.
Within a new browser, run localhost/
Set the data directory to D:\TeamCity\Data, and click on the Proceed button
From the DB Connection, select MS SQL
Insert the credentials created earlier for SQL Server and click on the Proceed button
Read through and accept the Licence Agreement, and click Continue
Administrative User Accounts
Insert credentials for the default TeamCity administrator account. Make sure the password is strong enough. To keep things consistent, I have reused the same name as before.
You don’t want users of TeamCity to be accessing the site using the default Administrator account, so create a new user for daily use.
Select Administration | Users
Click on Create user account button
Enter all the user details and credentials and click on Create User button
Setup TeamCity as a NuGet Server
When the project is created, it will be generating a nuget file that will be supplied to Octopus, so TeamCity will need to be configured as a NuGet server
Select Administration | NuGet
Click on the Enable button
Click on the NuGet.exe tab
Click on Fetch NuGet
Select the latest version, at the time of this post it was 3.3.0 and click the Add button, and then wait until the agent has been updated
TeamCity Octopus Plug-In
Stop the TeamCity Server Service
Copy the file Octopus.TeamCity.zip to D:\TeamCity\Data\plugins (D:\TeamCity\Data\ is the TeamCity data directory )
Start the TeamCity Server service.
If you access TeamCity while it is still installing the plug-in you will get a maintenance page displayed
At this point TeamCity is ready for use, and a new project can be created. However will pause this for now as will need to install and configure the Octopus server as this is required for the project to be created.
Setting up and configurating the Octopus Deploy server will be discussed in Part 2.
This is continued in Building a Continuous Integration Environment for Sitecore Part 2 – Octopus Deploy
This is awesome.. more of a user guide than a blog post 🙂
Great post Darren, Really helpful!