In any software development project a Continuous Integration/ Continuous Deployment DevOps environment is essential. A recent project I elected to make use of TeamCity & Octopus Deploy all on an Azure stack.
In this post I twill detail the steps on how to install and configure Team City 2017.x on a Ubuntu 16.X server.
Install Database software
Team City is able to store TeamCity stores build history, users, build results and some run time data to a number of Relation Database Management Systems(RDBMS) including
- Postrgre SQL
- MS SQL
- Default Internal DB(HSQL)
In my particular case I make use of Postgres SQL, Install Postgres SQL on ubuntu
Download & Install Team city
Download the latest TeamCity for linux from Jetbrains.
After the download completes unpack the file
tar -xzf TeamCity-2017.1.1.tar.gz
We will install TeamCity to the
opt so we need to move the TeamCity Directory to
/opt/ and set permissions to the user running the TeamCity Application.
sudo mkdir /opt/jetbrains
$userthe owner of teamcity & teamagent
Configure TeamCity to start automatically with the correct use by creating a script to start and stop TeamCity. We’ll create a simple bash script using the
nano text editor.
sudo nano /etc/init.d/teamcity
If you are going to running the team city service under username other than the one you are currently installing it with then you will need to replace
$user in the code snippet with that username.
Copy and paste the following ocde into the editor.
Change the permissions required to execute the script and add it to the starup to nesure Team City is started whenever the server is start/restart
sudo chmod +x /etc/init.d/teamcity
Download database driver
The database drivers are usually not included in the TeamCity set up files. We will need to download the PostGres Driver seperately and place them in the
Change into the directory
Download the driver
We are now ready to start Team City and begin the configuration in the Team City UI
sudo /etc/init.d/teamcity start
http://[Server name or IP]:8111 and verify that you see “TeamCity First Start” page.
Congratulations TeamCity is installed continue the steps on the web page to configure it.
Teamcity build agent installation
- If you install TeamCity bundled with a Tomcat servlet container, or opt to install an agent for Windows, both the server and one build agent named
Default Agentare installed on the same machine. This is not a recommended setup for production purposes because of security concerns and since the build procedure can slow down the responsiveness of the webUI and overall TeamCity server functioning. If you need more build agents, perform the procedure described below.
- If you need the agent to run a operating system different from the TeamCity server, perform the procedure described below.
- For production installations, it is recommended to adjust the Agent’s JVM parameters to include the
Download build agent archive from your TeamCity server
Unzip it in separate directory
Copy agent’s settings file
sudo cp conf/buildAgent.dist.properties conf/buildAgent.properties
Edit this file
sudo nano conf/buildAgent.properties
There are fields which you must update
your TeamCity server address:
Make bin files executable
sudo chmod u+x bin/*.sh
Build agent usage
Add build agent to
rc.local for autostart after system reboot
<agent home>/launcher/conf/wrapper.conf file can also be used to alter the agent JVM parameters.
The user account used to run build agent service must have enough rights to start/stop the agent service, as described above.
Automatic Agent Start under Linux
To run agent automatically on the machine boot under Linux, configure daemon process with the
agent.sh start command to start it and
agent.sh stop command to stop it. Refer to an example procedure below
- Navigate to the services start/stop services scripts directory
- Open the build agent service script
sudo vim buildagent
- Paste the following into the file
- Set the permissions to execute the file
sudo chmod +x buildagent
- Make links to start the agent service on the machine boot and on restarts using the appropriate tool
- For Debian/Ubuntu
sudo update-rc.d buildagent defaults
- For Red Hat/CentOS
sudo chkconfig buildagent on
- At the end, starting the Build Agent, and Team City will pick it up
sudo /etc/init.d/buildagent start