Teamcity Installation For Deployment Using Bitbucket

Below are the steps to create a TeamCity installation for deployment using Bitbucket.

Live Web server

Pre-requisites

In the solution in Visual Studio, you will need:

  • NuGet folder

    With:

  • nuget.config
  • nuget.exe
  • nuget.targets

Project folder

You will also require a Build directory:

  • Build
  • dev.build
  • Microsoft.Web.Publishing.Tasks.dll
  • stage.build
  • production.build

Bitbucket details:

https://bitbucket.org/gocompanyName/projectName-cms

[email protected]:gocompanyName/projectName-cms.git

Also, Install

Git for Windows

Tortoise Git for windows

During installation make sure to select Putty for SSH,

  1. Check that the server has enough CPU & RAM.

  2. Acquire correct 'new' server details.

  3. Check IIS is installed and running.

  4. Install Visual Studio Community (latest version) - This ensures the latest version of .NET is installed and the build agents that Team City uses are also installed. Plus it's extremely useful for the server side, debugging etc.

  5. Download and install the latest version of TeamCity.

  6. Start Installer

  7. Set the port to 8080

  8. Install to the default directory

  9. Make sure services are set to run under the SYSTEM account.

  10. Save default build agent settings -> Just click Save.

  11. Copy the Microsoft JDBC Driver (in drivers folder) - Into the following directory,

    C:\ProgramData\JetBrains\TeamCity\lib\jdbc

  12. During the installer, the process selects MS SQL Server and adds the following credentials.

  13. Database Setup,

    - Create a new, empty database and call it TeamCity - with 'SA' permissions (default)

    - Do not add Instance name (leave blank)

    - Database name: 'TeamCity'

    - username: sa

    - password: password for the sa account

  14. Create a User account,

    Username: admin

    Password: admin password here

  15. Navigate to TeamCity: http://localhost:8080/

  16. Create a Project:

    Name: PROJECTNAME

    ProjectId: ProjectName

    Description: PROJECTNAME

  17. Create a new Build Configuration.

    Name: PROJECTNAME_Web

    Project Configuration Id: ProjectName_ProjectNameWeb

  18. Install Putty if it isn't already installed
  19. Run Putty
  20. Generate a new key.
  21. Save public as public.txt in C:\SSH
  22. Save private as private.ppk C:\SSH
  23. In TeamCity - Go to project settings -> SSH -> Upload new key. Upload the private key.
  24. Leave Putty Open and running with the key in the window as you need this for a copy and paste operation later.
  25. Then go to VCS Roots ( New VCS (Version Control Settings) section.)
  26. Set up VCS

    - Type of VCS: Git

    - VCS Name: PROJECTNAMEWeb

    - Fetch URL: [email protected]:gocompanyName/projectName-cms.git (or clone link of the git repo)

    - Push URL: leave blank

    - Default branch: refs/heads/master

    - Then leave everything else as the default setting apart from the Authentication Method. Set to the uploaded key. Choose the private key.

    - Click Save (When you have completed the next step you can test the connection.)

  27. Log into Bitbucket -> Account Settings --> SSH Keys

    - Click Add Key

    - Give it a meaningful name.

    - Copy and paste the private key from pUtty

    - Click save.

  28. Make sure the project builds transformation file
  29. Back into TeamCity

    - Project Settings -> General Settings -> Build COnfigurations -> Edit

    - From left menu go to Build Steps.

  30. In the project folder in windows explorer, locate the Build directory and create a copy of the stage.build, rename to release.build.

    - Update the <Configuration tag to'Release'. <Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration>

    - Update the OutputFolder to exact location: <OutputFolder>C:\Websites\Production\CompanyName.ProjectName.Web</OutputFolder>

  31. Next we need to create the Web.config file version in Visual Studio.

    - You should be able to create a new release version of the web.config file using the Configuration Manager tool.

    - Copy the contents of stage to set up the correct parameters.

    - Update this with the correct server & connection details.

  32. Once you're happy with the configuration files, add them to source control, commit and push. Make sure they are set to debug=false, trace=false.

  33. Once committed, go back to the TeamCity installation and navigate to,

    <Root project> -> PROJECTNAME -> PROJECTNAME_Web -> Edit Settings -> Build Steps -> Auto-Detect Build Steps

    - Select: Build/release.build

  34. In the edit screen, you can add value as in the TeamCity image in the folder.
  35. Finally, run the build; it should deploy to the correct folder.
  36. Copy it across any static files which are not committed to source control.
  37. Check that the correct settings are in the config files. Update and re-commit if necessary and then re-deploy to update the files -- do not copy directly to the deployment folder.
  38. Finally set up a website in IIS and configure with the correct domain name to the correct assigned address.

Make sure to add permissions to the folder to which Umbraco is installed.

- NETWORK SERVICE & IIS_USERS (both full permissions).


Similar Articles