Skip to content

Instantly share code, notes, and snippets.

@colin-kiegel
Last active May 18, 2022 16:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save colin-kiegel/f035f71cc1d5fd5ffffe to your computer and use it in GitHub Desktop.
Save colin-kiegel/f035f71cc1d5fd5ffffe to your computer and use it in GitHub Desktop.
TeamCity
#!/bin/sh
### BEGIN INIT INFO
# Provides: TeamCity_BuildAgent
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start build agent daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO
DIR="/opt/teamcity/buildAgent/bin"
USER="teamcity"
case "$1" in
start)
echo "Starting Team City BuildAgent"
start-stop-daemon --start --chuid $USER --chdir $DIR --exec ./agent.sh start
;;
stop)
echo "Stopping Team City BuildAgent"
start-stop-daemon --start --chuid $USER --chdir $DIR --exec ./agent.sh stop
;;
restart)
echo "Restarting Team City BuildAgent"
start-stop-daemon --start --chuid $USER --chdir $DIR --exec ./agent.sh stop
start-stop-daemon --start --chuid $USER --chdir $DIR --exec ./agent.sh start
;;
*)
echo "Usage: service teamcitiy-agent {start|stop|restart}"
exit 1
;;
esac
exit 0
#!/bin/bash
#
# manual download via: https://www.jetbrains.com/teamcity/download/download-thanks.html?platform=linux
# download teamcity
VERSION="9.1.5"
SOURCE="https://download.jetbrains.com/teamcity/TeamCity-${VERSION}.tar.gz"
sudo wget -c $SOURCE -O /tmp/TeamCity.tar.gz
# NOTE: Before upgrades read the changelog and make a backup
# http://localhost:8111/admin/admin.html?item=backup
# sudo service teamcity-server stop
# sudo service teamcity-agent stop
# install team city
sudo tar -xvf /tmp/TeamCity.tar.gz -C /opt
sudo rm -rf /tmp/TeamCity.tar.gz
sudo mv /opt/TeamCity /opt/teamcity
sudo mkdir /var/opt/teamcity
# create user
sudo useradd -m teamcity
sudo chown -R teamcity /opt/teamcity /var/opt/teamcity
# sudo usermod -a -G users teamcity # optional: add teamcity to additional groups
# create init.d script
INIT_AGENT="https://gist.githubusercontent.com/colin-kiegel/f035f71cc1d5fd5ffffe/raw/teamcity-agent.sh"
INIT_SERVER="https://gist.githubusercontent.com/colin-kiegel/f035f71cc1d5fd5ffffe/raw/teamcity-server.sh"
sudo wget $INIT_AGENT -O /etc/init.d/teamcity-agent
sudo wget $INIT_SERVER -O /etc/init.d/teamcity-server
sudo chmod 775 /etc/init.d/teamcity-*
sudo update-rc.d teamcity-agent defaults
sudo update-rc.d teamcity-server defaults
# start services
sudo service teamcity-server start
sudo service teamcity-agent start
#!/bin/sh
### BEGIN INIT INFO
# Provides: TeamCity_Server
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start teamcity server at boot time
# Description: Enable service provided by daemon.
### END INIT INFO
export TEAMCITY_DATA_PATH="/var/opt/teamcity/"
DIR="/opt/teamcity/bin/"
USER="teamcity"
case $1 in
start)
echo "Starting Team City Server"
start-stop-daemon --start --chuid $USER --chdir $DIR --exec ./teamcity-server.sh start
;;
stop)
echo "Stopping Team City Server"
start-stop-daemon --start --chuid $USER --chdir $DIR --exec ./teamcity-server.sh stop
;;
restart)
echo "Restarting Team City Server"
start-stop-daemon --start --chuid $USER --chdir $DIR --exec ./teamcity-server.sh stop
start-stop-daemon --start --chuid $USER --chdir $DIR --exec ./teamcity-server.sh start
;;
*)
echo "Usage: service teamcitiy-server {start|stop|restart}"
exit 1
;;
esac
exit 0
@colin-kiegel
Copy link
Author

derived from https://gist.github.com/sandcastle/9282638/

Install Database (e.g. MySQL)
Proceed with Configuration (https://confluence.jetbrains.com/display/TCD9/Installing+and+Configuring+the+TeamCity+Server)

By default, TeamCity runs on http://localhost:8111/ and has one registered build agent that runs on the same computer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment