For one of my recent projects I needed to set up Continuous Integration from scratch on a server. Having never done this before I found myself assembling all the required components, installing them, and configuring them (and struggling now and then through some of the gotchas that came up).
To save anyone who may have to do this in the future a headache, I documented the entire process. And instead of just keeping that information within our walls, I’m also sharing my process with the world here on our blog.
Components Needed
Microsoft SQL Server 2016 Express
Microsoft SQL Server Management Studio
TeamCity
Microsoft Build Tools 2015
This needs to match the version of your Visual Studio to work, but it’s usually part of the VS install
Octopus Server
Octopus Install
Install JDBC Drivers
Most likely you will need JDBC drivers.
Download the latest JDBC drivers from here.
Unzip the downloaded package and copy the .jar file to C:\ProgramData\JetBrains\TeamCity\lib\jdbc (this is the default location and may be a hidden folder).
TeamCity Server Setup
I’m going to assume you can install Microsoft SQL Server 2016 Express, SQL Server Management Studio, and Build Tools without any help from me. Although, note your SQL Server instance name (we’ll need that later).
So let’s jump right to installing and configuring TeamCity.
Run the TeamCity installer.
After you click through a few installation windows, specify the desired port number through which you want TeamCity to communicate and click Next. Refer to these instructions if you want to change it later.
The installation will continue with its configuration. This may take a while. When it’s complete, you are presented with a Configure Build Agent Properties box. Click Save.
The Select Service Account for Server box displays. Specify the appropriate Domain, Username, and Password. These will typically be the credentials used to log into the server. Click Next.
Note: You may be prompted for this information twice.
Continue through the configuration boxes and click Finish.
After configuration is complete, the TeamCity First Start page displays in a browser window. TeamCity recommends using Internet Explorer for this.
Verify the Data Directory location and click Proceed.
The Database Connection Setup page displays. Select “MS SQL Server” as the database type and, if necessary, specify the Database host[:port], Database Instance name, Database name, and Authentication method. Select “Windows authentication” as the Authentication method.
Click Proceed.
Note: If you will be using a remote database, refer to the TeamCity documentation.
If the Create Administrator Account page displays, proceed to step 22.
If you receive either of these messages, proceed to step 10:
The TCP/IP connection to the host localhost, port 1433 has failed. Error: “Connection refused: connect. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.”.
SQL exception: The TCP/IP connection to the host localhost, port 1433 has failed. Error: “Connection refused: connect. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.”.
Open the Computer Management window and enable your TCP/IP connection for SQL Server Network Configuration.
Open the Component Services window and restart the SQL Server service.
Return to the TeamCity Database Connection Setup page in your browser and click Proceed. This will verify that steps 10-11 worked. The following error message should display:
SQL error when doing: Taking a connection from the data source: no sqljdbc_auth in java.library.path
Unzip the JDBC driver and copy the sqljdbc_auth.dll file to the lib folder under the TeamCity install location (e.g., C:\TeamCity\lib).
Open the System Properties box (Windows Control Panel -> System and Security -> System -> Advanced system settings), click the Advanced tab, and click Environment Variables.
The Environment Variables box is displayed. Click New in the System Variables section.
The New System Variable box is displayed. Specify the following values and click OK:
Name: TEAMCITY_SERVER_OPTS
Value: -Djava.library.path=c:\TeamCity\lib
Launch SQL Server Express to create a TeamCity database and database user. Ensure that the database Collation is “SQL_Latin1_General_CP1_CS_AS”.
Ensure the database user has db_owner role membership.
Return to the Component Services window and restart the TeamCity service.
Return to the TeamCity Database Connection Setup page in your browser and refresh the page.
Click Proceed.
The Create Administrator Account page displays. Specify a Username, and create and reenter a Password. Click Create Account.
TeamCity Project Setup
Navigate to your TeamCity page in your browser of choice.
Click New Project from the Projects menu.
Enter a Name for the project and click Create.
Click Edit Project Settings.
Expand the Project Settings menu on the left and click VCS Roots. Then click Create VCS root.
Complete all the fields, select the appropriate Authentication method, and click OK.
Note: The VCS RootName is your main Github Repo or similar source control.
Click General Settings in the menu on the left and click Create build configuration.
Click Build Step in the Build Configuration Settings menu and click Add build step.
Before you can run a build you may run into a “Team city unmet requirement: MSBuildTools12.0_x86_Path exists” message. This means you don’t have the appropriate build tools installed on the server. Download build tools and restart TeamCity and TeamCityAgent on the server. Alternatively, you can also copy the build tools from your dev machine into the appropriate location on your server.
Hopefully these steps will help get you through some of the gotchas that come with getting all these components set up for Continuous Integration.
The post Setting Up Continuous Integration with TeamCity appeared first on Don't Panic Labs.