Teamcity and mysql installation on ubuntu

Install TeamCity 8

  1. Download TeamCity. You can get the latest URL from the downloads page.
     wget http://download.jetbrains.com/teamcity/TeamCity-8.1.4.tar.gz
  2. Unzip the downloaded file:
     tar xfz TeamCity-8.1.4.tar.gz
  3. Move the resulting TeamCity folder to the installation directory. I chose to install TeamCity in /opt/jetbrains/TeamCity:
     sudo mkdir /opt/jetbrains ; sudo mv TeamCity/ /opt/jetbrains
  4. Install Java, if necessary: See this post.
  5. Create a user for TeamCity:
     sudo useradd teamcity
  6. Configure permissions:
     sudo chown -R teamcity:teamcity /opt/jetbrains/TeamCity
  7. Configure TeamCity to start automatically with the correct user. The following steps are necessary:
    1. Create a file teamcity in /etc/init.d with the following content:
       #!/bin/sh
       # /etc/init.d/teamcity -  startup script for teamcity
       export TEAMCITY_DATA_PATH="/opt/jetbrains/TeamCity/.BuildServer"
       export TEAMCITY_SERVER_OPTS=-Djava.awt.headless=true # Configure TeamCity for use on a headless OS.
              
       case $1 in
       start)
        start-stop-daemon --start  -c teamcity --exec /opt/jetbrains/TeamCity/bin/runAll.sh start
       ;;
              
       stop)
        start-stop-daemon --start -c teamcity  --exec  /opt/jetbrains/TeamCity/bin/runAll.sh stop
       ;;
              
       esac
              
       exit 0
    2. Register the file as a startup script:
       sudo update-rc.d teamcity defaults
    3. Make the file executable:
       sudo chmod +x /etc/init.d/teamcity
  8. If you use TeamCity behind an Apache that works as a reverse proxy, add the following to the file /opt/jetbrains/TeamCity/conf/server.xml. Add it below the already existing <Connector ... /> tag:
     <Connector port="8543" protocol="org.apache.coyote.http11.Http11NioProtocol"
                 connectionTimeout="60000"
                 useBodyEncodingForURI="true"
                 socket.txBufSize="64000"
                 socket.rxBufSize="64000"
                 tcpNoDelay="1"
                 scheme="https"
                 proxyName="<ServerName of the virtual server in Apache>"
                 proxyPort="443"/>
  9. See this post to learn the necessary configuration in Apache if you want to use it as a reverse proxy.
  10. Start TeamCity:
    sudo service teamcity start
  11. Navigate to http://<your server>:8111 and verify that you are getting the “TeamCity First Start” page.
  12. Click “Proceed” once.
  13. Stop TeamCity:
    sudo service teamcity stop
Note: The default port for TeamCity on Linux is 8111. If you want to use port 80, TeamCity has to run as root.
Alternate approaches to make TeamCity reachable via Port 80 are:
References:
  1. TeamCity installation guide
  2. Install the Oracle JRE 7.
  3. Permissions and automatic start-up script: TeamCity server on Ubuntu

Install and configure database

TeamCity comes with an internal database. This database is unsupported by JetBrains and not meant for production use. JetBrains suggests the use of MySQL and so that’s what we are going to use:

Install MySQL

sudo apt-get install mysql-server  
Make sure you specify a password for the MySQL root user when prompted.

Setup MySQL for TeamCity:

  1. Start MySQL console:
     sudo mysql -u root -p
    When prompted, enter the password you specified during installation.
  2. Create TeamCity database:
     create database teamcity character set UTF8 collate utf8_bin;
  3. Use TeamCity database:
     USE teamcity
  4. Create TeamCity user:
     create user 'teamcityuser'@'localhost' identified by '<password>';
  5. Give TeamCity user all privileges on the database:
     grant all privileges on teamcity.* to 'teamcityuser'@'localhost';
    This is necessary because TeamCity actively changes the schema.

Configure TeamCity to use MySQL

  1. Download MySQL JDBC driver from http://dev.mysql.com/downloads/connector/j/:
     wget http://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.31.tar.gz -O mysql-connector.tar.gz
  2. Extract it:
     tar zxvf mysql-connector.tar.gz
  3. Move mysql-connector-java-5.1.31-bin.jar from the extracted directory to /opt/jetbrains/TeamCity/.BuildServer/lib/jdbc/:
     sudo mv mysql-connector-java-5.1.31/mysql-connector-java-5.1.31-bin.jar /opt/jetbrains/TeamCity/.BuildServer/lib/jdbc/
  4. Fix the permissions for the file:
     sudo chown teamcity:teamcity /opt/jetbrains/TeamCity/.BuildServer/lib/jdbc/mysql-connector-java-5.1.31-bin.jar
  5. Start TeamCity:
     service teamcity start
  6. Navigate to http://<your server>:8111.
  7. Click “Proceed”
  8. You will now be on the “TeamCity Database Creation” screen. Perform the following settings:
    1. Select MySQL as the database type
    2. If you get the message that the MySQL driver is not could not be found or is not loaded, click on “Refresh JDBC drivers”. You should then see the text “Loaded MySQL JDBC driver version: 5.1”.
    3. Enter teamcity as “Database name”.
    4. Enter teamcityuser as “User name”.
    5. For “Password”, enter the password you used when creating the database user.
  9. Click “Proceed”. If the button is not active, select another database type from the dropdown list and then select MySQL again. The button should now be active.
  10. Wait while TeamCity creates the database and initializes itself.
  11. Accept the license agreement.
  12. Create an administrator account.
  13. You should now be seeing the TeamCity profile page.
  14. In the upper right corner, click on Administration, then select Global Settings under the Server Administration heading on the left side.
  15. Verify the TeamCity configuration that is being displayed and make sure it says that it uses MySQL as the database.

Comments

Popular posts from this blog

HAproxy logging

tomcat catalina coyote jasper cluster

NFS mount add in fstab _netdev instead of default | firewall-cmd --list-all